Merge lp://qastaging/~bratsche/xsplash/setgid into lp://qastaging/xsplash

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~bratsche/xsplash/setgid
Merge into: lp://qastaging/xsplash
Diff against target: 56 lines
1 file modified
src/xsplash.c (+17/-8)
To merge this branch: bzr merge lp://qastaging/~bratsche/xsplash/setgid
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+12788@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
Ted Gould (ted) wrote :

From the patch attached to bug 439272:

Description: setuid()'s return must be checked in the case that some RLIMIT
 or other issue does not stop the transition. Additionally, setresuid()
 should be used so that the process cannot regain its prior uid.

review: Needs Fixing
82. By Cody Russell

use setresuid/setresgid

Revision history for this message
Cody Russell (bratsche) wrote :

> From the patch attached to bug 439272:
>
> Description: setuid()'s return must be checked in the case that some RLIMIT
> or other issue does not stop the transition. Additionally, setresuid()
> should be used so that the process cannot regain its prior uid.

Okay, pushed a new revision that switches to setresuid/setresgid.

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xsplash.c'
2--- src/xsplash.c 2009-10-01 20:56:55 +0000
3+++ src/xsplash.c 2009-10-04 00:15:21 +0000
4@@ -17,10 +17,12 @@
5 * Cody Russell <crussell@canonical.com>
6 */
7
8+#define _GNU_SOURCE
9+#include <unistd.h>
10+
11 #include <stdlib.h>
12 #include <math.h>
13 #include <string.h>
14-#include <unistd.h>
15 #include <pwd.h>
16 #include <dirent.h>
17
18@@ -913,14 +915,13 @@
19 int
20 main (int argc, char *argv[])
21 {
22- XsplashServer *server;
23- GError *error = NULL;
24- GOptionContext *context;
25+ XsplashServer *server;
26+ GError *error = NULL;
27+ GOptionContext *context;
28 DBusGConnection *system_bus;
29 DBusGProxy *bus_proxy;
30 guint nameret = 0;
31- struct passwd *pwd;
32- uid_t uid;
33+ struct passwd *pwd;
34
35 pwd = getpwnam (XSPLASH_USER);
36 if (pwd == NULL)
37@@ -929,9 +930,17 @@
38 return 1;
39 }
40
41- uid = pwd->pw_uid;
42+ if (setresgid (pwd->pw_gid, pwd->pw_gid, pwd->pw_gid))
43+ {
44+ g_error ("Failed to setresgid to `%s'", XSPLASH_USER);
45+ return 1;
46+ }
47
48- setuid (uid);
49+ if (setresuid (pwd->pw_uid, pwd->pw_uid, pwd->pw_uid))
50+ {
51+ g_error ("Failed to setresuid to `%s'", XSPLASH_USER);
52+ return 1;
53+ }
54
55 context = g_option_context_new ("xsplash");
56 g_option_context_add_main_entries (context,

Subscribers

People subscribed via source and target branches