Xref: utzoo comp.unix.questions:5887 comp.unix.wizards:6775 Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!ihnp4!homxb!mtuxo!mtgzz!avr From: avr@mtgzz.UUCP (XMRP50000[jcm]-a.v.reed) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: execution environment (checking if in .profile) Summary: Also check for head process on tty Keywords: sh,exec Message-ID: <3682@mtgzz.UUCP> Date: 29 Feb 88 20:15:20 GMT References: <7162@tut.cis.ohio-state.edu> <3668@mtgzz.UUCP> <7349@tut.cis.ohio-state.edu> Distribution: na Organization: AT&T, Middletown NJ Lines: 33 In article <7349@tut.cis.ohio-state.edu>, lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: > >> Is there a way for a program to tell if it was executed > >> 1) via a users .profile or 2) by a user on their command line? > >Thus, if your user's login shell is ksh, put in /etc/profile > > TMOUT=0 ; export TMOUT ; readonly TMOUT > >and then have the program check the value of TMOUT in env. > While writing this I thought of a way to defeat this (albeit obscurely). > This might work in the .profile > /bin/ksh<<-EOF > TMOUT=2313 ;program > EOF > Since the readonly attribute is not propogated to children, TMOUT gets set > and the program will run. However, it is easy to check whether the ppid is that of the head process (normally = the login shell) on the user's tty, and assume the worse if it isn't. Adam Reed (mtgzz!avr)