View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000897 | 1003.1(2013)/Issue7+TC1 | System Interfaces | public | 2014-11-28 23:19 | 2019-06-10 08:54 |
Reporter | safinaskar | Assigned To | |||
Priority | normal | Severity | Editorial | Type | Enhancement Request |
Status | Closed | Resolution | Accepted As Marked | ||
Name | Askar Safin | ||||
Organization | |||||
User Reference | |||||
Section | getuid | ||||
Page Number | 2013 edition, p. 1091 | ||||
Line Number | 36714 | ||||
Interp Status | --- | ||||
Final Accepted Text | See 0000897:0002456. | ||||
Summary | 0000897: setreuid(getuid(), getuid()) seems not rational | ||||
Description | getuid typically is system call. And this is possible that uid is not cached in standard library. And this is very unlikely compiler can optimize two syscalls to one. And examples in POSIX manuals should be ideal. :) So, for performance reasons (to avoid lots of context switches), please do the following: | ||||
Desired Action | line 36714 -setreuid(getuid(), getuid()); +uid_t u = getuid(); +setreuid(u, u); | ||||
Tags | tc2-2008 |
|
It seems odd that the example of how to set the effective user ID to the real user ID makes use of the optional (XSI) setreuid() function, instead of the mandatory seteuid() function. Change from: The following example sets the effective user ID and the real user ID of the current process to the real user ID of the caller. #include <unistd.h> #include <sys/types.h> ... setreuid(getuid(), getuid());to: The following example sets the effective user ID of the calling process to the real user ID. #include <unistd.h> ... seteuid(getuid()); |
|
The existing suggestion: > setreuid(getuid(), getuid()); also sets the saved set-user-ID to the real user ID. The suggested replacement: > seteuid(getuid()); does not. The setre{u,g}id() interfaces are probably XSI only because the versions in XSI and in pre-4.4BSD had slightly different semantics when mapped into saved set-*-ID logic...though both versions do the Right Thing when invoked per the example. |
|
Yes, my proposed change means different behaviour as regards saved set-user-ID. However, that's another argument in favour of changing to seteuid(), since the setreuid() example code does more than the description above it says it does (and the example's title implies). |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-11-28 23:19 | safinaskar | New Issue | |
2014-11-28 23:19 | safinaskar | Name | => Askar Safin |
2014-11-28 23:19 | safinaskar | Section | => getuid |
2014-11-28 23:19 | safinaskar | Page Number | => 2013 edition, p. 1091 |
2014-11-28 23:19 | safinaskar | Line Number | => 36714 |
2014-12-01 15:36 | geoffclare | Note Added: 0002456 | |
2014-12-02 06:38 | philip-guenther | Note Added: 0002466 | |
2014-12-02 14:19 | geoffclare | Note Added: 0002468 | |
2015-03-05 16:16 | Don Cragun | Interp Status | => --- |
2015-03-05 16:16 | Don Cragun | Final Accepted Text | => See 0000897:0002456. |
2015-03-05 16:16 | Don Cragun | Status | New => Resolved |
2015-03-05 16:16 | Don Cragun | Resolution | Open => Accepted As Marked |
2015-03-05 16:16 | Don Cragun | Tag Attached: tc2-2008 | |
2019-06-10 08:54 | agadmin | Status | Resolved => Closed |