Date: Thu, 22 Nov 2001 07:55:52 +0100 From: Rogier Steehouder <r.j.s@gmx.net> To: Dave VanAuken <dave@hawk-systems.com> Cc: questions@FreeBSD.ORG Subject: Re: determine user home directory from non-priv user Message-ID: <20011122075552.A576@localhost> In-Reply-To: <DBEIKNMKGOBGNDHAAKGNOEOGKEAA.dave@hawk-systems.com>; from dave@hawk-systems.com on Wed, Nov 21, 2001 at 02:34:15PM -0500 References: <DBEIKNMKGOBGNDHAAKGNOEOGKEAA.dave@hawk-systems.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 21-11-2001 14:34 (-0500), Dave VanAuken wrote: > from a non-priv account we need to determine the home directory of a user... > used for interaction with web server. > > Obviously pw is out of the question because we do not wish to give priv to the > web server (despite it being an enclosed system)... any other system base > alternatives? > > For example, need to find out what user "Joe"'s home dir is... we would execute > our program ("finduserdir" in this example) in the following manner to get the > desired results: > server# finduserdir Joe > /usr/home/Joe > server# > > Again, we need to do this from the webserver or other non-priv userid. > > Appreciate any comments. > > Dave There are several possible solutions. As an example, I have attached a perl CGI script I use myself. In general, You read /etc/passwd (which should be world-readable) and select the information you want. With kind regards, Rogier Steehouder -- ___ _ -O_\ // | / Rogier Steehouder //\ / \ r.j.s@gmx.net // \ <---------------------- 25m ----------------------> --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=userpages #!/usr/bin/perl #+-------------------------------------------------------------------+ #| Display a list of all users with homepages (links available) | #+-------------------------------------------------------------------+ # HTTP Header: print("Content-type: text/html\n", "Expires: Sat, 11 Aug 2001 00:00:00 GMT\n", "Cache-control: no-cache\n\n"); # HTML Body: print("<ul class=\"userlink\">\n"); while (($user, $name, $dir) = (getpwent())[0,6,7]) { if (-d "$dir/www") { print("\t<li class=\"userlink\"><a href=\"/~$user/\" class=\"userlink\">$name</a></li>\n"); } } print("</ul>\n"); # vim:set ts=4 sw=4 et : --gKMricLos+KVdGMg-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011122075552.A576>