getpwnam question

Discussion in 'Perl Misc' started by perlUSER, Nov 25, 2005.

  1. perlUSER

    perlUSER Guest

    Hello all;
    I am writing a perl program to lock the user ID if it exists in a file
    that I receive on a daily basis. I could use "lsuser -a account_locked
    user_ID" to see whether user_ID is locked or not. If locked then I skip
    the record and go to the next record. Is there a perl function to get
    this account_locked flag value something like below?

    my $userPw = getpwnam($user);
    my $home = $userPw -> dir;
    my $uid = $userPw -> uid;
    my $gecos = $userPw -> gecos;

    I tried this but didn't work:

    my $account_locked = $userPw -> account_locked;

    The above function gives some information but not the
    account_locked=true or account_locked=false.

    I appreciate any help on this problem.

    Thanks in advance.

    Regards,
    Sri.
    perlUSER, Nov 25, 2005
    #1
    1. Advertising

  2. perlUSER

    Anno Siegel Guest

    perlUSER <> wrote in comp.lang.perl.misc:
    > Hello all;
    > I am writing a perl program to lock the user ID if it exists in a file
    > that I receive on a daily basis. I could use "lsuser -a account_locked
    > user_ID" to see whether user_ID is locked or not. If locked then I skip
    > the record and go to the next record. Is there a perl function to get
    > this account_locked flag value something like below?
    >
    > my $userPw = getpwnam($user);
    > my $home = $userPw -> dir;
    > my $uid = $userPw -> uid;
    > my $gecos = $userPw -> gecos;
    >
    > I tried this but didn't work:
    >
    > my $account_locked = $userPw -> account_locked;
    >
    > The above function gives some information but not the
    > account_locked=true or account_locked=false.


    The property of an account being "locked" is a peculiarity of AIX, it
    doesn't exist in other Unix systems. It is stored in the file
    /etc/security/user and not in /etc/passwd like other properties of an
    account. Consequently, getpwnam() (and other account-related get-functions)
    don't know about this property.

    You'll have to use the external lsuser command (another AIX specialty) or
    parse /etc/security/user yourself to get that info.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    Anno Siegel, Nov 28, 2005
    #2
    1. Advertising

  3. Anno Siegel wrote:
    > perlUSER <> wrote in comp.lang.perl.misc:
    >>Hello all;
    >>I am writing a perl program to lock the user ID if it exists in a file
    >>that I receive on a daily basis. I could use "lsuser -a account_locked
    >>user_ID" to see whether user_ID is locked or not. If locked then I skip
    >>the record and go to the next record. Is there a perl function to get
    >>this account_locked flag value something like below?
    >>
    >> my $userPw = getpwnam($user);
    >> my $home = $userPw -> dir;
    >> my $uid = $userPw -> uid;
    >> my $gecos = $userPw -> gecos;
    >>
    >>I tried this but didn't work:
    >>
    >> my $account_locked = $userPw -> account_locked;
    >>
    >>The above function gives some information but not the
    >>account_locked=true or account_locked=false.

    >
    > The property of an account being "locked" is a peculiarity of AIX, it
    > doesn't exist in other Unix systems.


    I know that you could lock accounts on DG/UX and I know you can on Linux.

    man 1 passwd

    Look for the -l switch.


    > It is stored in the file
    > /etc/security/user and not in /etc/passwd like other properties of an
    > account.


    In Linux it is stored in the /etc/shadow file. The first character of the
    password field is set to '!'.


    > Consequently, getpwnam() (and other account-related get-functions)
    > don't know about this property.
    >
    > You'll have to use the external lsuser command (another AIX specialty) or
    > parse /etc/security/user yourself to get that info.



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn, Nov 29, 2005
    #3
  4. perlUSER

    Anno Siegel Guest

    perlUSER <> wrote in comp.lang.perl.misc
    > Hello all
    > I am writing a perl program to lock the user ID if it exists in

    fil
    > that I receive on a daily basis. I could use "lsuser -

    account_locke
    > user_ID" to see whether user_ID is locked or not. If locked then

    ski
    > the record and go to the next record. Is there a perl function t

    ge
    > this account_locked flag value something like below
    >
    > my $userPw = getpwnam($user)
    > my $home = $userPw -> dir
    > my $uid = $userPw -> uid
    > my $gecos = $userPw -> gecos
    >
    > I tried this but didn't work
    >
    > my $account_locked = $userPw -> account_locked
    >
    > The above function gives some information but not th
    > account_locked=true or account_locked=false
    >

    The property of an account being "locked" is a peculiarity of AIX, i
    doesn't exist in other Unix systems. It is stored in the fil
    /etc/security/user and not in /etc/passwd like other properties of a
    account. Consequently, getpwnam() (and other account-relate
    get-functions
    don't know about this property

    You'll have to use the external lsuser command (another AIX specialty
    o
    parse /etc/security/user yourself to get that info

    Ann
    --
    If you want to post a followup via groups.google.com, don't us
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers
    Anno Siegel, Nov 29, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Keller

    Problem with getpwnam() syscall

    Thomas Keller, Jan 19, 2004, in forum: Perl
    Replies:
    1
    Views:
    1,367
    Joe Smith
    Jan 20, 2004
  2. Jason Williard

    Using getpwnam() with CGI

    Jason Williard, Apr 22, 2005, in forum: Perl
    Replies:
    0
    Views:
    2,705
    Jason Williard
    Apr 22, 2005
  3. gga
    Replies:
    1
    Views:
    277
    Daniel Berger
    Mar 8, 2005
  4. Thomas Keller

    Problem with getpwnam() syscall

    Thomas Keller, Jan 20, 2004, in forum: Perl Misc
    Replies:
    5
    Views:
    171
    Ben Morrow
    Jan 20, 2004
  5. Jason Williard

    Using getpwnam() with CGI

    Jason Williard, Apr 23, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    180
    Alan J. Flavell
    Apr 24, 2005
Loading...

Share This Page