… | |
… | |
25 | |
25 | |
26 | #include "../config.h" |
26 | #include "../config.h" |
27 | |
27 | |
28 | #include "ptytty.h" |
28 | #include "ptytty.h" |
29 | |
29 | |
30 | // helper/proxy support |
|
|
31 | |
|
|
32 | #if PTYTTY_HELPER |
|
|
33 | |
|
|
34 | #include <csignal> |
30 | #include <csignal> |
35 | |
31 | |
36 | #include <sys/types.h> |
32 | #include <sys/types.h> |
37 | #include <sys/socket.h> |
33 | #include <sys/socket.h> |
38 | #include <unistd.h> |
34 | #include <unistd.h> |
39 | #include <fcntl.h> |
35 | #include <fcntl.h> |
|
|
36 | |
|
|
37 | // helper/proxy support |
|
|
38 | |
|
|
39 | #if PTYTTY_HELPER |
40 | |
40 | |
41 | static int sock_fd = -1, lock_fd = -1; |
41 | static int sock_fd = -1, lock_fd = -1; |
42 | static int helper_pid, owner_pid; |
42 | static int helper_pid, owner_pid; |
43 | |
43 | |
44 | struct command |
44 | struct command |
… | |
… | |
303 | || gid != getegid ()) |
303 | || gid != getegid ()) |
304 | { |
304 | { |
305 | #if PTYTTY_HELPER |
305 | #if PTYTTY_HELPER |
306 | use_helper (); |
306 | use_helper (); |
307 | #else |
307 | #else |
308 | ptytty_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n"); |
308 | ptytty_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n", 0); |
309 | #endif |
309 | #endif |
310 | |
310 | |
311 | drop_privileges (); |
311 | drop_privileges (); |
312 | } |
312 | } |
313 | } |
313 | } |
… | |
… | |
326 | setregid (gid, gid); |
326 | setregid (gid, gid); |
327 | setreuid (uid, uid); |
327 | setreuid (uid, uid); |
328 | #elif HAVE_SETUID |
328 | #elif HAVE_SETUID |
329 | setgid (gid); |
329 | setgid (gid); |
330 | setuid (uid); |
330 | setuid (uid); |
|
|
331 | #else |
|
|
332 | # error no way to drop privileges, configure failed? |
331 | #endif |
333 | #endif |
332 | |
334 | |
333 | if (uid != geteuid () |
335 | if (uid != geteuid () |
334 | || gid != getegid ()) |
336 | || gid != getegid ()) |
335 | ptytty_fatal ("unable to drop privileges, aborting.\n"); |
337 | ptytty_fatal ("unable to drop privileges, aborting.\n"); |