From owner-freebsd-questions@FreeBSD.ORG Fri Sep 17 18:51:06 2004 Return-Path: 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 142FF16A4CE for ; Fri, 17 Sep 2004 18:51:06 +0000 (GMT) Received: from ppsw-8.csi.cam.ac.uk (ppsw-8.csi.cam.ac.uk [131.111.8.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98BC443D46 for ; Fri, 17 Sep 2004 18:51:05 +0000 (GMT) (envelope-from rtb27@cam.ac.uk) Received: from rtb27.robinson.cam.ac.uk ([131.111.217.214]:50115) by ppsw-8.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:465) with esmtp (SSLv3:RC4-MD5:128) (Exim 4.34) id 1C8Np1-0005P4-6Z (return-path rtb27@cam.ac.uk) for freebsd-questions@freebsd.org; Fri, 17 Sep 2004 19:51:03 +0100 From: Richard Bradley To: freebsd-questions@freebsd.org Date: Fri, 17 Sep 2004 19:50:19 +0000 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409171950.19717.rtb27@cam.ac.uk> X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ X-Cam-AntiVirus: No virus found X-Cam-SpamDetails: Not scanned Subject: how to make an executable run as another user X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2004 18:51:06 -0000 Um. I feel silly asking this. But I can't work it out. I want a shell script to run as another user. I always thought this was easy to do with the setuid bit, but never tried it before. I read "man chmod" and found this: ..... 4000 (the setuid bit). Executable files with this bit set will run with effective uid set to the uid of the file owner. ..... s The set-user-ID-on-execution and set-group-ID-on-execution bits. .... And off I went. I wrote a shell script to output the current uid. I chown'ed it to another user. I "chmod +s"ed it. I ran it. It didn't work. ----- rtb27# cat test #! /bin/sh whoami rtb27# ll test -rwsr-sr-x 1 rich wheel 20 Sep 17 19:34 test rtb27# ./test root -------- Um. Help? Rich