Score:0

If I create a user account, does it also store information of the creator?

id flag

How do I get the username of the creator

For example i'm using root account to create a username maxi32

Now, by referencing this username maxi32, how can I know which user created his username?

So I'm expecting the output maxi32 will return username of root (the creator)

jpbrain avatar
ca flag
Hi Maxi32, as far as I know it is not that way. All users can only by created by root. So if you are a normal user you need to get root privileges to create another user. I am not sure if you can enable something in the journaling system to get a log of that. I will investigate.
jpbrain avatar
ca flag
Did some tests. see /var/log/auth.log. all "elevated" (root access) actions are recorded there.
id flag
Ok, that's the only log file that exist there? So, in the future we don't know the creator of that user if the log file is removed accidentally ? .. that sounds like an atheist that does not worship or remember their creator (an example).
jpbrain avatar
ca flag
Yes. There are things you can implement by modifying standard scripts but in general this is handled by security policies an only one admin :-)
id flag
@jpbrain what do you recommend when using script? I have workaround using a file flag, put uid value inside that file stored in user home directory when we created a new user using this bootscript https://stackoverflow.com/questions/15567887/execute-shell-script-everytime-a-new-user-is-created/15568230. then use that as reference but doesnt seems to be efficient.
id flag
At least the work around has a permanent file referencing the `uid` of the creator not a `/var/log/` file that can be easily removed. So, i'm not sure what is the best workaround or which is the best location to store this uid of the creator, so i can retrieve this easily by comparing with `/etc/passwd`
jpbrain avatar
ca flag
Maxi32 if you dig a litle bit you will find that /usr/sbin/adduser is a perl script that calls useradd. Inside the perl script you can add a line that dumps all data you need to a database or protected file whne finally useradd is called. as the execution of adduser has to be done by root you will need to check enviroment vairables but almost al the information needed is handled by that file. Keep in mind that even this can be bypassed.
jpbrain avatar
ca flag
To be more clear. If you do sudo, there is an environment variable SUDO_USER that tell who did sudo. If you do su -, you will need root password but the sudo env variable is gone. Just a log into auth.log will tell you who did su. So there is not straight answer for what you are looking for..
id flag
Thank you so much, i will try to modify the standard script.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.