home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6960 < prev    next >
Encoding:
Text File  |  1992-11-12  |  2.7 KB  |  83 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!think.com!yale.edu!ira.uka.de!chx400!bernina!karrer
  3. From: karrer@bernina.ethz.ch (Andreas Karrer)
  4. Subject: Perl4.035 on a Convex
  5. Message-ID: <1992Nov12.180859.5956@bernina.ethz.ch>
  6. Keywords: suidperl mechanism, perl4.035, Convex
  7. Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
  8. Date: Thu, 12 Nov 1992 18:08:59 GMT
  9. Lines: 72
  10.  
  11.  
  12. First a little history:
  13.  
  14.  - Up to ConvexOS 9.0, Convexen were vulnerable to the #!-setuid-script bug.
  15.  - With 9.0, the kernel simply refused to execute scripts with the
  16.    set[u|g]id bit set -- making suidperl unusable. I filed a problem
  17.    report, and, lo and behold:
  18.  - 10.0 made the kernel's behaviour upon encountering setuid script a
  19.    boot-time parameter:
  20.     0) 9.0 style (for the paranoid),
  21.     1) pre-9.0 style (for those who use their convex as a PC)
  22.     2) kernel passes the script to the interpreter, but ignores the
  23.        setuid bit.
  24.    2) is what is needed for taintperl/suidperl to work.
  25.  
  26. It was certainly reassuring to see my own words printed in the release notes,
  27. followed by a "Problem fixed". There _are_ vendors who react on user's
  28. complaints. Thanks Convex!
  29.  
  30. However, when trying to run a setuid taintperl script with the perl4.010
  31. supplied with 10.1, i get:
  32.  
  33.     % ./setuid-script
  34.     Can't reswap uid and euid
  35.  
  36. Bummer.  The message comes from perl.c when it tries to invoke setreuid().
  37.  
  38. So i compiled 4.035 with:
  39.  
  40.     Any additional cc flags? [] -pcc
  41.  
  42.     Any additional libraries? [] -lnsl -ldbm -lm -lcrypt
  43.         (Convex does not ship crypt.o in its libc.a anymore (intl.
  44.          version) so i put mine into /usr/local/lib/libcrypt.a)
  45.  
  46.     In config.sh, i set:
  47.         groupstype='gid_t'              (was int)
  48.         d_setregid='undef'              (was define)
  49.         d_setreuid='undef'              (was define)
  50.  
  51.     The last two are neccessary for suidperl to work. Convex _has_
  52.     setreuid(2)/setregid(2), but these work only for "POSIX mode processes".
  53.     I assume the -pcc flag above makes this perl non-POSIX.
  54.  
  55. After a surprisingly fast compilation (previous C optimizers spent ages on
  56. toke.c and eval.c) i got:
  57.  
  58.     % cat shscript
  59.     #!/bin/sh
  60.     whoami
  61.     % cat perlscript
  62.     #!/usr/bin/taintperl
  63.     print scalar getpwuid($>) , "\n";
  64.     % ls -l perlscript shscript
  65.     -rwsr-xr-x  1 root           55 Nov 12 18:11 perlscript
  66.     -rwsr-xr-x  1 root           17 Nov 12 18:12 shscript
  67.     % ./shscript; ./perlscript
  68.     karrer
  69.     root
  70.  
  71. Success!!!
  72.  
  73. BTW it is unwise to put perl into /usr/local/bin or somesuch on a
  74. Convex. Most of Convex' installation script are now written in perl;
  75. they assume the partition perl lives on is mounted. Also, save a copy
  76. of the perl that comes with ConvexOS.
  77.  
  78.  - Andi
  79.  
  80. +-----------
  81.   Andi Karrer, Communication Systems, ETH Zuerich, Switzerland
  82.   karrer@bernina.ethz.ch    - Objects in mirror are closer than they appear
  83.