From owner-freebsd-questions Wed Aug 8 22:13:49 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-27-141-144.mmcable.com [24.27.141.144]) by hub.freebsd.org (Postfix) with SMTP id BECDF37B401 for ; Wed, 8 Aug 2001 22:13:45 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 46853 invoked by uid 100); 9 Aug 2001 05:13:45 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15218.7177.143011.457023@guru.mired.org> Date: Thu, 9 Aug 2001 00:13:45 -0500 To: BinarySoul Cc: questions@freebsd.org Subject: Re: finding user of su In-Reply-To: <122679418@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ 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 [Format recovered from top posting.] BinarySoul types: > Eric Anderson wrote: > > Is there a tool (or how would I write one) that can tell me the original > > user after an su? Basically, if I su to root, how can I tell who I su'd > > from? > There are a lot of ways you can do that :) > Really... > You can just look at you environment: > Things like: > id -p | grep login Very nice. I didn't know id would do that. > ... > Well, I said, there are a lot of ways... > Even: > cat << lol > buh.c > #include > #include > int main(void){ > printf("%s\n",getlogin()); > return 0; > } > lol > > must work getlogin is what "id -p" uses, so the two solutions are pretty much the same. Like all the other cases, it only works if the user doesn't reset it. For getlogin, that needs something like this: #include #include int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "usage: %s \n", argv[0]) ; return 1 ; } if (setlogin(argv[1]) != 0) { perror("olo") ; return 1 ; } return 0; } http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message