From owner-freebsd-questions Wed Nov 21 22:56: 4 2001 Delivered-To: freebsd-questions@freebsd.org Received: from kabel203069.kabel.utwente.nl (kabel203069.kabel.utwente.nl [130.89.203.69]) by hub.freebsd.org (Postfix) with ESMTP id 3FA3637B416 for ; Wed, 21 Nov 2001 22:55:59 -0800 (PST) Received: by kabel203069.kabel.utwente.nl (Postfix, from userid 1000) id 5BD3C1F88; Thu, 22 Nov 2001 07:55:52 +0100 (CET) Date: Thu, 22 Nov 2001 07:55:52 +0100 From: Rogier Steehouder To: Dave VanAuken Cc: questions@FreeBSD.ORG Subject: Re: determine user home directory from non-priv user Message-ID: <20011122075552.A576@localhost> Mail-Followup-To: Rogier Steehouder , Dave VanAuken , questions@FreeBSD.ORG References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from dave@hawk-systems.com on Wed, Nov 21, 2001 at 02:34:15PM -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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("
    \n"); while (($user, $name, $dir) = (getpwent())[0,6,7]) { if (-d "$dir/www") { print("\t
  • $name
  • \n"); } } print("
\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