Passwd & Groups - pkoper/gtm-posix GitHub Wiki

getpwnam

getpwnam^posix(.user,.n) takes the user name, calls getpwnam(3) and returns passwd struct fields in n.

GTM>d getpwnam^posix("pkoper",.n) zwr
errno=0
n("dir")="/home/pkoper"
n("gecos","fullname")="Piotr Koper"
n("gecos","homephone")=""
n("gecos","office")=""
n("gecos","workphone")=""
n("gid")=1000
n("name")="pkoper"
n("passwd")="x"
n("shell")="/bin/bash"
n("uid")=1000
GTM>

getpwuid

getpwuid^posix(.id,.n) takes the UID, calls getpwuid(3) and returns passwd struct fields in n.

GTM>d getpwuid^posix(0,.n) zwr
errno=0
n("dir")="/root"
n("gecos","fullname")="root"
n("gecos","homephone")=""
n("gecos","office")=""
n("gecos","workphone")=""
n("gid")=0
n("name")="root"
n("passwd")="x"
n("shell")="/bin/bash"
n("uid")=0
GTM>

getgrnam

getgrnam^posix(.group,.n) takes the GID, calls getgrnam(3) and returns groups struct fields in n.

GTM>d getgrnam^posix("dialout",.n) zwr
errno=0
n("gid")=20
n("mem")="pkoper|www-data"
n("name")="dialout"
n("passwd")="x"
GTM>

getgrgid

getgrgid^posix(.id,.n) takes the GID, calls getgrgid(3) and returns groups struct fields in n.

GTM>d getgrgid^posix(0,.n) zwr
errno=0
n("gid")=0
n("mem")=""
n("name")="root"
n("passwd")="x"
GTM>

getgrouplist

$$getgrouplist^posix(.user) takes the user name and returns groups names the user belongs to. The implementation does not use getgrouplist(3), so as to assure portability.

GTM>w $$getgrouplist^posix("pkoper")
lp|dialout|cdrom|floppy|sudo|audio|video|plugdev
GTM>