X-Git-Url: https://git.hcoop.net/hcoop/debian/libnss-afs.git/blobdiff_plain/03b6b479897df2f195120622e69f87aede855589..5fea146a0336c48c8628edabfde1288ae988d249:/nss_afs_test.c diff --git a/nss_afs_test.c b/nss_afs_test.c dissimilarity index 83% index f5c9c03..45c345f 100644 --- a/nss_afs_test.c +++ b/nss_afs_test.c @@ -1,64 +1,57 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc,char **argv,char **envp) { - int buflen=1000; - char buffer[buflen]; - char *buf; - char *arg; - int uid; - int res; - - buf=buffer; - if ( argc != 2 ) { - printf("Usage: %s [name or id]\n\nAsks (a hopefully running) ptdbnssd for an AFSID or a PT-username, returns both.\n",argv[0]); - exit(1); - } - arg=argv[1]; - if ( ( arg[0] > '0' ) && ( arg[0] < '9' ) ) { - // NAME-Lookup - uid=atoi(arg); - res=ptsid2name(uid,&buf,&buflen); - if ( res == NSS_STATUS_SUCCESS ) { - printf("uid=%i name=%s\n",uid,buffer); - //printf("homedir_method=%i, shell_method=%i\n",conf.homedirs_method,conf.shells_method); - return 0; - } else { - if ( res == NSS_STATUS_NOTFOUND ) { - printf("W: AFSID %i not found.\n",uid); - return 1; - } else { - if ( res == NSS_STATUS_UNAVAIL ) { - printf("E: Error talking to ptdbnssd.\n"); - return 2; - } - } - } - } else { - buf=buffer; - res=ptsname2id(arg,&uid); - if ( res == NSS_STATUS_SUCCESS ) { - printf("uid=%i name=%s\n",uid,arg); - //printf("homedir_method=%i, shell_method=%i\n",conf.homedirs_method,conf.shells_method); - return 0; - } else { - if ( res == NSS_STATUS_NOTFOUND ) { - printf("W: PT-user '%s' not found.\n",buf); - return 1; - } else { - if ( res == NSS_STATUS_UNAVAIL ) { - printf("E: Error talking to ptdbnssd.\n"); - return 2; - } - } - } - } -} +/***************************************************************************** + * libnss-afs (nss_afs_test.c) + * + * Copyright 2008, licensed under GNU Library General Public License (LGPL) + * see COPYING file for details + * + * by Adam Megacz + * derived from Frank Burkhardt's libnss_ptdb, + * which was derived from Todd M. Lewis' libnss_pts + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc,char **argv,char **envp) { + int buflen=1000; + char buffer[buflen]; + char *buf, *arg, *name; + int uid; + int res; + + buf=buffer; + if ( argc != 2 ) { + printf("Usage: %s [name or id]\n\n",argv[0]); + printf("Attempts lookup of a username or userid.\n"); + printf("Statically linked against nss_afs.c.\n"); + exit(1); + } + arg=argv[1]; + if ( ( arg[0] > '0' ) && ( arg[0] < '9' ) ) { + uid=atoi(arg); + name = buf; + res=ptsid2name(uid,&buf,&buflen); + } else { + name = arg; + res=ptsname2id(arg,&uid); + } + switch(res) { + case NSS_STATUS_SUCCESS: + printf("uid=%i name=%s\n",uid,name); + break; + case NSS_STATUS_NOTFOUND: + printf("not found.\n"); + break; + case NSS_STATUS_UNAVAIL: + printf("unable to contact ptserver or library internal error.\n"); + break; + } +}