<?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: deactivate new users if NOT accessed the system - NON trusted in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299619#M183604</link>
    <description>echo was for testing....&lt;BR /&gt;&lt;BR /&gt;manuel contreras        &lt;BR /&gt;&lt;BR /&gt;echo "/usr/sam/lbin/usermod.sam -p "*" $x "</description>
    <pubDate>Tue, 08 Jun 2004 16:38:25 GMT</pubDate>
    <dc:creator>Manuel Contreras</dc:creator>
    <dc:date>2004-06-08T16:38:25Z</dc:date>
    <item>
      <title>deactivate new users if NOT accessed the system - NON trusted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299618#M183603</link>
      <description>The following script will deactivate any users who have not accessed the system in X number of days....&lt;BR /&gt;&lt;BR /&gt;I would like to limit this to NEW users only, any sugetions?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you have to copy the /etc/passwd file to control location which is re-created after the script is run.&lt;BR /&gt;&lt;BR /&gt;I was thinking this could be initiated via crontab once every 24 hrs...&lt;BR /&gt;&lt;BR /&gt;All input is appreciated,&lt;BR /&gt;manuel contreras&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#this script will check for new users and deactivate accounts &lt;BR /&gt;#if users have NOT accessed the system in Xnumber of days.&lt;BR /&gt;&lt;BR /&gt;diff /etc/passwd /usr/local/unix/Security/passwd.copy | grep "&amp;lt;" | egrep -v 'root:' &amp;gt; \&lt;BR /&gt;     /usr/local/unix/Security/passwd.diff&lt;BR /&gt;&lt;BR /&gt;awk -F: '{print $1, $6}' /usr/local/unix/Security/passwd.diff | awk '{print $2, $3}' &amp;gt; \&lt;BR /&gt;     /usr/local/unix/Security/newUSERS.lst&lt;BR /&gt;&lt;BR /&gt;currentD=`date '+%d %e'`&lt;BR /&gt;&lt;BR /&gt;for x in `cat /usr/local/unix/Security/newUSERS.lst | awk '{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;  usrHOME=`grep $x /usr/local/unix/Security/newUSERS.lst | awk '{print $2}'`&lt;BR /&gt;  echo "$usrHOME will be checked"&lt;BR /&gt;  usrHIST=`find "$usrHOME"/.sh_history -mtime +3 -print`&lt;BR /&gt;echo "$userHIST"&lt;BR /&gt;  if [ -n "$usrHIST" ]&lt;BR /&gt;     then&lt;BR /&gt;         echo "today is - $currentD "&lt;BR /&gt;         echo "the user was created more than 3days ago - today is $currentD "&lt;BR /&gt;         echo""&lt;BR /&gt;         echo "now checking If user has logged on the system"&lt;BR /&gt;         userSTAT=`last -1 $x | grep begins `&lt;BR /&gt;            if [ -n "$userSTAT" ]&lt;BR /&gt;               then&lt;BR /&gt;                  echo "user will be deactivated"&lt;BR /&gt;                  echo "/usr/sam/lbin/usermod.sam -p "*" $x "&lt;BR /&gt;                  echo""&lt;BR /&gt;            fi&lt;BR /&gt;     else&lt;BR /&gt;         echo "user has accessed the system recently"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cp /etc/passwd /usr/local/unix/Security/passwd.copy&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Jun 2004 16:37:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299618#M183603</guid>
      <dc:creator>Manuel Contreras</dc:creator>
      <dc:date>2004-06-08T16:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: deactivate new users if NOT accessed the system - NON trusted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299619#M183604</link>
      <description>echo was for testing....&lt;BR /&gt;&lt;BR /&gt;manuel contreras        &lt;BR /&gt;&lt;BR /&gt;echo "/usr/sam/lbin/usermod.sam -p "*" $x "</description>
      <pubDate>Tue, 08 Jun 2004 16:38:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299619#M183604</guid>
      <dc:creator>Manuel Contreras</dc:creator>
      <dc:date>2004-06-08T16:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: deactivate new users if NOT accessed the system - NON trusted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299620#M183605</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If I understand your script correctly,&lt;BR /&gt;&lt;BR /&gt;You are taking a difference of passwd.copy and the current passwd file and arriving at the new users. Say a user 'user1' got created just before you ran this script. That user would automatically become 'old' with the command 'cp /etc/passwd /usr/local/unix/Security/passwd.copy'. So, you would need to incorporate further logic to retain the new users until 3 days. I would maintain four files - as newusers.now, newusers.1dayold, newusers.2dayold, newusers.3dayold. Everytime the script is run, it checks for each user in all these files and takes the users out of the files if the activity was found. The users left in newusers.3dayold file will be appended to newusers.disabled file and newusers.2dayold will be moved as newusers.3dayold etc.,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also," grep $x /usr/local/unix/Security/newUSERS.lst | awk '{print $2}'" may not work always. For ex., users user1 and user11. So, add a delimiter like ":" or "," while you are making this user list.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Jun 2004 17:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299620#M183605</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-06-08T17:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: deactivate new users if NOT accessed the system - NON trusted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299621#M183606</link>
      <description>you are correct on the logic...It needs further attention.&lt;BR /&gt;&lt;BR /&gt;maybe I can have another job simply copy the /etc/passwd to control copy once a week, and take this out of the deactiveCHECKER?&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;manuel contreras&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Jun 2004 17:31:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299621#M183606</guid>
      <dc:creator>Manuel Contreras</dc:creator>
      <dc:date>2004-06-08T17:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: deactivate new users if NOT accessed the system - NON trusted</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299622#M183607</link>
      <description>One general comment about working with /etc/passwd using the hp-ux's grep command. I normally work on Tru64/AIX systems and was recently porting a useradd script to HP-UX. I was using the -w option with grep command on other flavours and I noted that the HP-UX's grep don't have the -w option. Finally we ended up downloading the gnu grep (ggrep) utility to replace the hp-ux grep.&lt;BR /&gt;&lt;BR /&gt;The danger with simple grep is that it will give output for partial matching on a word and in case of users, it could be costly. for eg, &lt;BR /&gt;# grep smith newUSERS.lst&lt;BR /&gt;smith&lt;BR /&gt;smithj&lt;BR /&gt;smithjo&lt;BR /&gt;&lt;BR /&gt;where as&lt;BR /&gt;#grep -w smith newUSERS.lst, would only give,&lt;BR /&gt;smith&lt;BR /&gt;&lt;BR /&gt;This is from experience, and you may want to consider either doig more checks, or using ggrep to do exact word matching in case of usernames.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Abdul.</description>
      <pubDate>Tue, 08 Jun 2004 17:34:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/deactivate-new-users-if-not-accessed-the-system-non-trusted/m-p/3299622#M183607</guid>
      <dc:creator>Abdul Rahiman</dc:creator>
      <dc:date>2004-06-08T17:34:35Z</dc:date>
    </item>
  </channel>
</rss>

