I'm attempting to set up my computer such that I can authenticate myself using an external device connected to a python script. I started by replacing the login
program in inittab
with my own program, and I've been able to get into a bash shell. The problem is that it doesn't get a fresh environment like the one that is (I presume) given with login
. I know there are ways for me to mess with the environment, but i haven't seen a way to give it a "default" configuration, if even such a thing makes sense.
Some ideas:
First of all it would be better in most cases to use the pluggable login architecture PAM. This will ensure, that all PAM-enabled applications and services can use the authentification method (ssh for example) and that there is no way to bypass it using regular services.
If you really want to replace login
i'd suggest to clear the environment by yourselves using unsetenv
for each environment variable set (you may use environ
to determine the variables already set). After cleaning up the environment you may use a exec
-like call to replace your program with a bash
, the environment will be unchanged in this context. You may want to add the command line argument -l
to start up bash as it would have been invoked by login
.
Bash is running some init scripts on startup. You may check /etc/profile
, /etc/bashrc
and similar files for environment variables you don't want to be set.
If you want to be dependant on env
(wich is not so bad, since it should be present on every linux system out there) you can use env -i bash
to call bash in a clean environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With