Received: (at submit) by bugs.debian.org; 11 Mar 2001 21:48:04 +0000 From erich@erich.dyn.mucl.de Sun Mar 11 15:48:04 2001 Return-path: Received: from mailout06.sul.t-online.com [194.25.134.19] by master.debian.org with esmtp (Exim 3.12 1 (Debian)) id 14cDh5-0005DG-00; Sun, 11 Mar 2001 15:48:03 -0600 Received: from fwd00.sul.t-online.com by mailout06.sul.t-online.com with smtp id 14cDh1-0007qG-03; Sun, 11 Mar 2001 22:47:59 +0100 Received: from erich (520031278902-0001@[217.80.37.95]) by fmrl00.sul.t-online.com with esmtp id 14cDgu-0L97BoC; Sun, 11 Mar 2001 22:47:52 +0100 Received: by erich (Postfix, from userid 1000) id 0B89548583; Sun, 11 Mar 2001 22:46:02 +0100 (CET) From: Erich Schubert To: Debian Bug Tracking System Subject: wishlist: tool for printing user's home directory X-Reportbug-Version: 1.14 X-Mailer: reportbug 1.14 Date: Sun, 11 Mar 2001 22:46:02 +0100 Message-Id: <20010311214602.0B89548583@erich> X-Sender: 520031278902-0001@t-dialin.net Delivered-To: submit@bugs.debian.org Package: shellutils Version: 2.0.11-2 Severity: wishlist i'd like to have a tool for printing the home directory of a user (real user / effective user / user passed on command line) I've run across this need 3 times in shell scripting last week... I wrote these scripts in perl then... Maybe there is a simlar utility already in Debian, but i havn't found it and everybody told me to awk /etc/passwd - but i'm running LDAP... And i think such a tool belong's right next to "groups" and "id". Might even be upstream-wishlist... This surely isn't hard to write, basically just something like this: (Sorry for the bad code, but this is the first C Program i ever wrote on my own and havn't hacked some other's program ;) ------- #include #include #include #include #include int main(int argc, char **argv) { struct passwd *user; if (argc <=1) { /* without parameters, get current user id's home */ user=getpwuid(geteuid()); } else if (strcmp(argv[1],"-r") == 0) { /* get real user id */ user=getpwuid(getuid()); } else if (strcmp(argv[1],"-h") == 0) { /* show help screen */ printf("Usage: homedir [OPTION] [USERNAME]\n"); printf("Print home directory of USERNAME, or the current user.\n\n"); printf(" -r print home of the real instead of effecive user\n"); printf(" -h display this help and exit\n"); exit(0); } else { user=getpwnam(argv[1]); } if (user) { printf("%s\n",user->pw_dir); } else { fprintf(stderr, "Error: could not get home directory\n"); exit(1); } exit(0); } ------- this lack's to course more detailed error messages and i18n/l10n... Greetings, Erich -- System Information Debian Release: testing/unstable Architecture: i386 Kernel: Linux erich.xmldesign.de 2.4.2-ac2 #1 Fre Feb 23 13:48:55 CET 2001 i686 Versions of packages shellutils depends on: ii libc6 2.2.2-1 GNU C Library: Shared libraries an ii login 20000902-3 System login tools