From owner-freebsd-questions@FreeBSD.ORG Mon Jan 2 08:42:16 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 057BD16A41F for ; Mon, 2 Jan 2006 08:42:16 +0000 (GMT) (envelope-from scott@lackluster.net) Received: from tinker.apex13.com (tinker.apex13.com [69.72.250.186]) by mx1.FreeBSD.org (Postfix) with ESMTP id E5E7E43D79 for ; Mon, 2 Jan 2006 08:42:07 +0000 (GMT) (envelope-from scott@lackluster.net) Received: from localhost (localhost.apex13.com [127.0.0.1]) by tinker.apex13.com (Postfix) with ESMTP id 2C1FA398EF; Mon, 2 Jan 2006 03:42:03 -0500 (EST) Received: from tinker.apex13.com ([127.0.0.1]) by localhost (tinker.apex13.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 65829-07; Mon, 2 Jan 2006 03:42:01 -0500 (EST) Received: from [192.168.0.108] (ip68-8-61-4.sd.sd.cox.net [68.8.61.4]) by tinker.apex13.com (Postfix) with ESMTP id 6D9F539872; Mon, 2 Jan 2006 03:42:01 -0500 (EST) Message-ID: <43B8E770.5090300@lackluster.net> Date: Mon, 02 Jan 2006 00:42:24 -0800 From: Scott Smith User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mike Esquardez References: In-Reply-To: X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.3 (20050822) (FreeBSD) at localhost Cc: freebsd-questions@freebsd.org Subject: Re: Help with Difficult Startup Script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jan 2006 08:42:16 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 su user -c command If you are running it as an rc script, you'll probably want to use su for the fetchmail command, since init scripts run as root anyway. I'm not sure if what you're doing is the best way to go about things though... Also, I would be very careful with running scripts as root that are not owned by root. If the user mik owns the script, and that account is compromised, they have a very easy path to root access. Scott Mike Esquardez wrote: > Hello, I am trying to make a script that runs the following commands. > This is difficult for me because I dont know how to switch users. > Currently these are the commands that I am trying to script. > > # fetchmail ?d 1000 & (this needs to be run as username mik) > # su -l root > # /home/mik/myfilter & (this needs to be run as root) > > I know I have to make the files executable and .sh extension then put > them in /usr/local/etc/rc.d to get them to run at startup but I am not > sure how to make these commands run as different users. > > Is there a way to have something like this? (i know runas isnt a real > shell command) > > #/bin/sh > runas "mik" fetchmail & > runas "root" /home/mik/myfilter & > > Any help would be very much helpful. mik > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today it's FREE! > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" - -- scott@lackluster.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) iD8DBQFDuOdwKBeC2yZ3EEsRArnzAKCJJ/pvathcwgJdBAbfIjJcktfXwACdGj14 Pm/TpuOrHJ5c4yx5eSnvxSI= =KyLU -----END PGP SIGNATURE-----