Annotation of coherent/g/usr/lib/uucp/tay104/uudir.c, revision 1.1

1.1     ! root        1: /* uudir.c
        !             2:    Create a directory owned by uucp.  This is Unix specific.
        !             3: 
        !             4:    Copyright (C) 1992 Ian Lance Taylor
        !             5: 
        !             6:    This file is part of the Taylor UUCP package.
        !             7: 
        !             8:    This program is free software; you can redistribute it and/or
        !             9:    modify it under the terms of the GNU General Public License as
        !            10:    published by the Free Software Foundation; either version 2 of the
        !            11:    License, or (at your option) any later version.
        !            12: 
        !            13:    This program is distributed in the hope that it will be useful, but
        !            14:    WITHOUT ANY WARRANTY; without even the implied warranty of
        !            15:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            16:    General Public License for more details.
        !            17: 
        !            18:    You should have received a copy of the GNU General Public License
        !            19:    along with this program; if not, write to the Free Software
        !            20:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            21: 
        !            22:    The author of the program may be contacted at [email protected] or
        !            23:    c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
        !            24:    */
        !            25: 
        !            26: #if USE_RCS_ID
        !            27: const char uudir_rcsid[] = "$Id: uudir.c,v 1.1 93/07/30 07:59:03 bin Exp Locker: bin $";
        !            28: #endif
        !            29: 
        !            30: #include "sysdep.h"
        !            31: 
        !            32: #include <pwd.h>
        !            33: 
        !            34: /* External functions.  */
        !            35: #if GETPWNAM_DECLARATION_OK
        !            36: #ifndef getpwnam
        !            37: extern struct passwd *getpwnam ();
        !            38: #endif
        !            39: #endif
        !            40: 
        !            41: /* This is a simple program which sets its real uid to uucp and then
        !            42:    invokes /bin/mkdir.  It is only used if the system does not support
        !            43:    the mkdir system call.  It must be installed suid to root.
        !            44: 
        !            45:    This program is needed because the UUCP programs will be run suid
        !            46:    to uucp.  On a system without the mkdir system call, /bin/mkdir is
        !            47:    a suid root program.  This means that /bin/mkdir always creates
        !            48:    directories using the real uid, rather than the effective uid.
        !            49:    This is wrong, since the UUCP programs always want to create
        !            50:    directories that are owned by uucp.  Therefore, this simple suid
        !            51:    root program is used to force /bin/mkdir into making a directory
        !            52:    owned by uucp.
        !            53: 
        !            54:    If we made the program publically executable, this would mean that
        !            55:    anybody could create a directory owned by uucp.  This is probably
        !            56:    not a good thing, but since the program must be owned by root we
        !            57:    can't simply make it executable only by uucp.  Therefore, the
        !            58:    Makefile hides the program away in /usr/lib/uucp/util, and makes
        !            59:    that directory searchable only by uucp.  This should prevent
        !            60:    anybody else from getting to the program.
        !            61: 
        !            62:    This is not a perfect solution, since any suid root program is by
        !            63:    definition a potential security hole.  I really can't see any way
        !            64:    to avoid this, though.  */
        !            65: 
        !            66: int
        !            67: main (argc, argv)
        !            68:      int argc;
        !            69:      char **argv;
        !            70: {
        !            71:   struct passwd *q;
        !            72:   const char *zprog, *zname;
        !            73: 
        !            74:   /* We don't print any error messages, since this program should
        !            75:      never be run directly by a user.  */
        !            76: 
        !            77:   if (argc != 2)
        !            78:     exit (EXIT_FAILURE);
        !            79: 
        !            80:   /* OWNER is passed in from the Makefile.  It will normally be
        !            81:      "uucp".  */
        !            82:   q = getpwnam (OWNER);
        !            83:   if (q == NULL)
        !            84:     exit (EXIT_FAILURE);
        !            85: 
        !            86:   if (setuid (q->pw_uid) < 0)
        !            87:     exit (EXIT_FAILURE);
        !            88: 
        !            89:   zprog = MKDIR_PROGRAM;
        !            90:   zname = strrchr (zprog, '/');
        !            91:   if (zname == NULL)
        !            92:     zname = zprog;
        !            93:   else
        !            94:     ++zname;
        !            95: 
        !            96:   (void) execl (zprog, zname, argv[1], (char *) NULL);
        !            97:   exit (EXIT_FAILURE);
        !            98: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.