<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: suid script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651720#M742352</link>
    <description>/usr/lbin/getprpw -m exptm &lt;USERNAME&gt;&lt;BR /&gt;will return&lt;BR /&gt;exptm=89   # That is the number of days till expiration.&lt;BR /&gt;&lt;BR /&gt;The script runs fine as root, but when I run it as a user it comes back&lt;BR /&gt;Not Superuser on the next line instead of the exptm=89&lt;/USERNAME&gt;</description>
    <pubDate>Tue, 18 Oct 2005 08:58:05 GMT</pubDate>
    <dc:creator>Belinda Dermody</dc:creator>
    <dc:date>2005-10-18T08:58:05Z</dc:date>
    <item>
      <title>suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651718#M742350</link>
      <description>I know suid scripts is a security risk,  I have a HPUX 11i system, my problem is I need to let the users know that there password is about to expire.  I have about 200 users and the 7 day warning is either ignore or they just do not see it.  The system goes into a Database Menu system and the users do not get to the Unix prompt (95% of them couldn't spell unix) and when they exit the database I log them off the system.  My problem is I am using the /usr/lbin/getprpw and if the results is less than 7 days to display BIGGER Message that they need to contact the HELP DESK to change there password.  &lt;BR /&gt;I did a 4755 on the script and it starts with a #!/usr/bin/sh  but when I test it under my userid it comes back.&lt;BR /&gt;Not Superuser</description>
      <pubDate>Tue, 18 Oct 2005 08:37:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651718#M742350</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2005-10-18T08:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651719#M742351</link>
      <description>So, how do you get the number of days left on the password lifetime using the /usr/lbin/getprpw command and what does your script return ? An error code ? if so, what is the error code (aka exit status) ? If no errors, what do you expoect to see that you can not see ?&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Oct 2005 08:52:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651719#M742351</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-10-18T08:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651720#M742352</link>
      <description>/usr/lbin/getprpw -m exptm &lt;USERNAME&gt;&lt;BR /&gt;will return&lt;BR /&gt;exptm=89   # That is the number of days till expiration.&lt;BR /&gt;&lt;BR /&gt;The script runs fine as root, but when I run it as a user it comes back&lt;BR /&gt;Not Superuser on the next line instead of the exptm=89&lt;/USERNAME&gt;</description>
      <pubDate>Tue, 18 Oct 2005 08:58:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651720#M742352</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2005-10-18T08:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651721#M742353</link>
      <description>My understanding is that a script cannot be SETUID (it can be set, but it's ignored).  Instead, a program can be setuid that a non-root script can execute.  We had a requirement that certain users be able to chown/chmod files that they did not own - so we wrote a c program to do it, then setuid it, and called it from a script.  Works like a charm.</description>
      <pubDate>Tue, 18 Oct 2005 09:46:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651721#M742353</guid>
      <dc:creator>Gary L. Paveza, Jr.</dc:creator>
      <dc:date>2005-10-18T09:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651722#M742354</link>
      <description>Thanks Gary, but boo hoo, that is not what I was looking for, I can write pretty good scripts in shell and a little perl and with advice from you guys, but C programming is out of my realm and I am too old to learn.  I do not want to use sudo because that means they will be putting in there passwd twice within a few seconds and most of the time for no reason for the sudo command.</description>
      <pubDate>Tue, 18 Oct 2005 09:50:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651722#M742354</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2005-10-18T09:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651723#M742355</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I would use "C" programming with a little help :&lt;BR /&gt;#####################################&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;&lt;BR /&gt;#define SCRIPT  "/usr/local/bin/security/yourscript.sh "&lt;BR /&gt;&lt;BR /&gt;main (argc,argv)&lt;BR /&gt;char **argv;&lt;BR /&gt;int argc;&lt;BR /&gt;{&lt;BR /&gt;  int i;&lt;BR /&gt;  char comm[200];&lt;BR /&gt;  (void)strcat(comm,SCRIPT);&lt;BR /&gt;/*  printf("commande : %s\n",comm); */&lt;BR /&gt;/*  printf("nb arg : %d\n",argc);  */&lt;BR /&gt;  for(i=1; i &amp;lt; argc ; i++) {&lt;BR /&gt;        (void)strcat(comm,argv[i]);&lt;BR /&gt;        (void)strcat(comm," ");&lt;BR /&gt;  }&lt;BR /&gt;/*  printf("commande : %s\n",comm); */&lt;BR /&gt;  system(comm);&lt;BR /&gt;}&lt;BR /&gt;######################################&lt;BR /&gt;compile this program (as root)&lt;BR /&gt;cc pgm.c -o pgm&lt;BR /&gt;mv pgm /usr/local/bin/security/.&lt;BR /&gt;(adapt for your directory)&lt;BR /&gt;The script &lt;YOURSCRIPT.SH&gt; is owned by root &lt;BR /&gt;with 0700 permission.&lt;BR /&gt;the program "pgm" will call the script with relevant parameter.&lt;BR /&gt;Please note full path for the script !&lt;BR /&gt;&lt;BR /&gt;the pgm will be owned by root with 4555 permission.&lt;BR /&gt;&lt;BR /&gt;test the script 1st (as root)&lt;BR /&gt;Wrapp it&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc&lt;BR /&gt;&lt;/YOURSCRIPT.SH&gt;&lt;/STRING.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 18 Oct 2005 11:53:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651723#M742355</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2005-10-18T11:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651724#M742356</link>
      <description>One problem with the proposed c-program... it gives everyone on the system root priv.  (on most systems this is not the intent)&lt;BR /&gt;&lt;BR /&gt;Here is the demonstration(my 0700 script just echos "hi"):&lt;BR /&gt;&lt;BR /&gt;I compiled the program:&lt;BR /&gt;# cc pgm.c -o pgm&lt;BR /&gt;# su fritzr&lt;BR /&gt;$ id&lt;BR /&gt;uid=13553(fritzr) gid=778(security)&lt;BR /&gt;$ ./rootgift ';id'&lt;BR /&gt;hi&lt;BR /&gt;uid=13553(fritzr) gid=778(security) euid=0(root)&lt;BR /&gt;&lt;BR /&gt;Substitute "id" with "rm -rf *" and an arbitrary user has just wiped your system.&lt;BR /&gt;&lt;BR /&gt;There are two problems with the program:  #1, unchecked buffer, #2 (the easier exploit), unchecked execution of arbitrary user arguments at elevated privilege.&lt;BR /&gt;&lt;BR /&gt;I'd suggest the following instead:&lt;BR /&gt;&lt;BR /&gt;#####################################&lt;BR /&gt;&lt;BR /&gt;main ()&lt;BR /&gt;{&lt;BR /&gt;setreuid(0,0);&lt;BR /&gt;system("/usr/lbin/getprpw -m exptm `id -nu`");&lt;BR /&gt;}&lt;BR /&gt;######################################&lt;BR /&gt;compile this program (as root)&lt;BR /&gt;cc daysleft.c -o daysleft&lt;BR /&gt;mv daysleft &lt;SOME non-world-writeable="" dir=""&gt;&lt;BR /&gt;Then make a script &lt;BR /&gt;with 0555 permission that runs pgm and parses the output.&lt;BR /&gt;&lt;BR /&gt;daysleft will be owned by root with 4555 permission.&lt;BR /&gt;&lt;BR /&gt;The reasons this *doesn't* create a security hole:&lt;BR /&gt;1) There is no unchecked buffer to overflow, and &lt;BR /&gt;2) there is no untrusted input run by a privileged program&lt;BR /&gt;&lt;/SOME&gt;</description>
      <pubDate>Wed, 19 Oct 2005 12:12:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651724#M742356</guid>
      <dc:creator>Robert Fritz</dc:creator>
      <dc:date>2005-10-19T12:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651725#M742357</link>
      <description>There is always a risk with SUID:&lt;BR /&gt;&lt;BR /&gt;PATH=/tmp:$PATH ; &lt;BR /&gt;echo ksh &amp;gt; /tmp/id ;&lt;BR /&gt;chmod 700 /tmp/id ;&lt;BR /&gt;./daysleft&lt;BR /&gt;&lt;BR /&gt;Instant root shell.</description>
      <pubDate>Thu, 20 Oct 2005 11:29:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651725#M742357</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2005-10-20T11:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651726#M742358</link>
      <description>Fair enough... I failed to specify the full path... guess I was typing too fast.  Substitute /usr/bin/id for id to close the hole.</description>
      <pubDate>Thu, 20 Oct 2005 11:38:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651726#M742358</guid>
      <dc:creator>Robert Fritz</dc:creator>
      <dc:date>2005-10-20T11:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651727#M742359</link>
      <description>You'll still need some date math.  exptm lists only the password expiration period.  I like GNU date (gdate) to do this in shell scripts, but there are scripts which will do similar things.  The following uses gdate, and does not use getprpw ...&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;PATH=/usr/bin:/usr/local/bin&lt;BR /&gt;&lt;BR /&gt;exptime=$(grep u_exp /tcb/files/auth/$(echo $LOGNAME | sed "s/^\(.\).*$/\1/")/$LOGNAME | sed "s/.*u_exp#\([^:]*\).*$/\1/")&lt;BR /&gt;chgtime=$(grep u_succhg /tcb/files/auth/$(echo $LOGNAME | sed "s/^\(.\).*$/\1/")/$LOGNAME | sed "s/.*u_succhg#\([^:]*\).*$/\1/")&lt;BR /&gt;&lt;BR /&gt;expires_on=$(gdate -d "January 1, 1970 $chgtime seconds $exptime seconds" +%Y%m%d)&lt;BR /&gt;expires_less_seven_days=$(gdate -d "$expires_on 7 days ago" +%Y%m%d)&lt;BR /&gt;today=$(gdate +%Y%m%d)&lt;BR /&gt;&lt;BR /&gt;echo Expires $expires_on, less seven days $expires_less_seven_days v $today $((expires_on-$today)) ...&lt;BR /&gt;&lt;BR /&gt;if [ $today -ge $expires_less_seven_days ]&lt;BR /&gt;then&lt;BR /&gt;     echo "Your password is expiring soon!"&lt;BR /&gt;     exit 1&lt;BR /&gt;else&lt;BR /&gt;     echo "No password change coming this week."&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Oct 2005 11:59:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651727#M742359</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2005-10-20T11:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651728#M742360</link>
      <description>Daniel, what I see I like, but I went to the GNU site and I couldn't find any reference for gdate and also the HP software site with no luck.  Could you point me to where you got it from...</description>
      <pubDate>Thu, 20 Oct 2005 12:53:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651728#M742360</guid>
      <dc:creator>Belinda Dermody</dc:creator>
      <dc:date>2005-10-20T12:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651729#M742361</link>
      <description>I saw the comment that you don't want to use sudo because the users would need to enter their password a second time, but didn't notice anyone addressing your point. What you stated is not necessarily true. There is an option when configuring a command or group that will allow the authorized users to execute the command with entering their password. Check out the sudo man page for the details. I don't remember the syntax off the top of my head, but I know this is possible.</description>
      <pubDate>Thu, 20 Oct 2005 15:28:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651729#M742361</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-10-20T15:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: suid script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651730#M742362</link>
      <description>Ah, sorry about the naming.  "gdate" is GNU "date" part of the shell-utils (now part of coreutils).  The prepending of the "g" is a fairly common practice, but it is not the default name.  I've not used this particular package, preferring to compile my own.  There seem to be some dependencies, which I donâ  t recall needing for the run-time for gdate, though.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Gnu/coreutils-5.2.1/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Gnu/coreutils-5.2.1/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Theyâ  ve also got sudo, which is fairly easy to use as well,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.8p9/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.8p9/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The syntax for the sudo config item without passwords is as follows (presuming your account is jmarrion):&lt;BR /&gt;&lt;BR /&gt;jmarrion ALL = NOPASSWD: /usr/lbin/getprpw&lt;BR /&gt;&lt;BR /&gt;or for a system group called â  itrcâ  :&lt;BR /&gt;&lt;BR /&gt;%itrc  ALL = NOPASSWD: /usr/lbin/getprpw&lt;BR /&gt;&lt;BR /&gt;"visudo" is the configuration command for sudo.&lt;BR /&gt;&lt;BR /&gt;WARNING:  This does not limit the use of getprpw to the calling user, so users would be able to read information other than their own.  Perhaps something would be better like:&lt;BR /&gt;&lt;BR /&gt;jmarrion ALL = NOPASSWD: /usr/local/bin/getexptm&lt;BR /&gt;&lt;BR /&gt;where getexptm is:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;/usr/lbin/getprpw $LOGNAME&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Oct 2005 05:34:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/suid-script-help/m-p/3651730#M742362</guid>
      <dc:creator>A. Daniel King_1</dc:creator>
      <dc:date>2005-10-25T05:34:11Z</dc:date>
    </item>
  </channel>
</rss>

