X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fpt_chown.c;h=466e1771e88eca1e3798c311c7edc075ae7fd7cd;hb=0aa49ea72a8764e3065ebbfc55459232ca8fb021;hp=d79ad3a87ca2405c8682df1de9fe6c31cb2a49ba;hpb=eae8e44ccfca3e367df3be11c3f5de48c4302093;p=gnulib.git diff --git a/lib/pt_chown.c b/lib/pt_chown.c index d79ad3a87..466e1771e 100644 --- a/lib/pt_chown.c +++ b/lib/pt_chown.c @@ -1,5 +1,5 @@ -/* pt_chown - helper program for `grantpt'. - Copyright (C) 1998, 1999, 2009, 2010 Free Software Foundation, Inc. +/* pt_chown - helper program for 'grantpt'. + Copyright (C) 1998-1999, 2009-2012 Free Software Foundation, Inc. Contributed by C. Scott Ananian , 1998. This program is free software: you can redistribute it and/or modify @@ -25,7 +25,8 @@ #include #include -#include "idpriv.h" +#include "root-uid.h" + #include "pty-private.h" /* For security reasons, we try to minimize the dependencies on libraries @@ -52,7 +53,7 @@ do_pt_chown (void) if (stat (pty, &st) < 0 || !S_ISCHR (st.st_mode)) return FAIL_EINVAL; - /* Get the group ID of the special `tty' group. */ + /* Get the group ID of the special 'tty' group. */ p = getgrnam (TTY_GROUP); gid = p ? p->gr_gid : getgid (); @@ -76,16 +77,15 @@ main (int argc, char *argv[]) { uid_t euid = geteuid (); - if (argc == 1 && euid == 0) + if (argc == 1 && euid == ROOT_UID) { /* Normal invocation of this program is with no arguments and with privileges. */ return do_pt_chown (); } - /* We aren't going to be using privileges, so drop them right now. */ - if (idpriv_drop () < 0) - return EXIT_FAILURE; + /* It would be possible to drop setuid/setgid privileges here. But it is not + really needed, since the code below only calls strcmp and [f]printf. */ { int do_help = 0; @@ -154,7 +154,7 @@ main (int argc, char *argv[]) } /* Check if we are properly installed. */ - if (euid != 0) + if (euid != ROOT_UID) { fprintf (stderr, "pt_chown: needs to be installed setuid 'root'\n"); return FAIL_EXEC;