passwd_info

passwd_info is a simple program that can query the /etc/passwd file for current user or specified user.
Download

passwd_info Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Kevin Waldron
  • Publisher web site:
  • http://www.zazzybob.com/sh_config.html

passwd_info Tags


passwd_info Description

passwd_info is a simple program that can query the /etc/passwd file for current user or specified user. passwd_info is a simple program that can query the /etc/passwd file for current user or specified user.USAGE: passwd_info Sample:#include < unistd.h >#include < stdlib.h >#include < stdio.h >#include < sys/types.h >#include < pwd.h >#include < string.h >struct passwd *pw;void print_usage(void);int main( int argc, char *argv[] ){ if ( argc > 2 ) { print_usage(); exit(1); } char *name; uid_t uid; gid_t gid; char *gecos; char *dir; char *shell; char *user_arg; if ( argv != NULL ) { user_arg=(char *)malloc(strlen(argv)); strcpy( user_arg, argv ); if ( (pw = getpwnam(user_arg) ) == NULL ) { fprintf( stderr, "Error: user %s does not existn", user_arg ); exit(1); } uid = pw->pw_uid; free(user_arg); } else /* get for current user */ { uid = getuid(); pw = getpwuid(uid); } name = pw->pw_name; gid = pw->pw_gid; gecos = pw->pw_gecos; dir = pw->pw_dir; shell = pw->pw_shell; printf( "/etc/passwd file information for %sn", name ); printf( "Username = %stUID = %dtGID = %dn", name, (int)uid, (int)gid ); printf( "GECOS = %snHome = %stShell = %sn", gecos, dir, shell ); exit(0);}void print_usage( void ){ fprintf( stderr, "USAGE: passwd_info n" );}


passwd_info Related Software