0

Everything was working just fine before but we have put in new restrictions on the users where we no longer have sudo ability.

To sum it up, I have custom functions which saved me 5+ minutes of running various commands, changing ownership of files/folders moving things around and cleanup.

With the removal of sudo from my profile I can only be me, or switch to the group user.

How can I have my script do things such as remove files owned by the group user or other things if I cannot make use of sudo?

I have tried switching to the group user in my .bashrc file then follow that with the commands and then exit out but that DOES NOT work. It only puts me into the shell as the group user and none of the variables defined in the .bashrc file are viewable. This goes for he export variables too.

My bashrc file is approximately 722 lines and slowly grows. I started this 4 years ago and have kept it as I transition to various projects.

The SA is saying to break up the .bashrc file and move things to the group user .bashrc file but my God that would be a nightmare as it would null and void basically everything that I and the other developers have been using.

My .bashrc file has literally been adopted by all the other developers as it requires minimal modifications per user (literally 1 thing needs to be changed in the file for each developer) in order for it to work.

Is there a solution or am I just HOSED on trying to keep using it?

Not sure what the correct terms are for this whole thing I'm doing but I hope someone understands what I am doing.

# switch to user
groupUser;
# test call out. This does not run
echo "Show me the var val ${testxyz};
exit;
echo "Back to me user ${USER}";

when .bashrc loads it is just showing me as the groupUser, none of the other stuff executes.

*

By groupUser, it is just an alias that allows me to switch to that user which is in the same group as my user but is the owner of select folders/files etc.

e.g. myUser:groupUser and groupUser:groupUser *

edjm
  • 135
  • 7
  • Relating https://unix.stackexchange.com/q/1087/117549 – Jeff Schaller Nov 29 '21 at 19:41
  • I'm not familiar with the groupUser command is it a script or alias that runs "sudo" or "su" in some way? – Jeff Schaller Nov 29 '21 at 19:41
  • "I can only be me, or switch to the group user" – And how do you do that, by calling the command groupUser? And that opens a shell for the group user? Can you do echo id | groupUser? – Hauke Laging Nov 29 '21 at 19:50
  • By groupUser, it is just an alias that allows me to switch to that user which is in the same group as my user but is the owner of select folders/files etc. – edjm Nov 29 '21 at 20:07
  • @HaukeLaging From a terminal window when I open it, the .bashrc executes and just shows that I'm the groupUser. The other commands that follow in the .bashrc do not execute so the echo does not work unless I were to type it in after the terminal loads. – edjm Nov 29 '21 at 20:11
  • My first reaction is "use expect", but without showing exactly how groupUser works, I don't know how much specific advice you'll get. – glenn jackman Nov 29 '21 at 20:35
  • Do you think it makes sense to have groupUser in .bashrc? Is the echo executed if you press -D in the group user shell? – Hauke Laging Nov 29 '21 at 21:03
  • groupUser is just another account on the development system – edjm Nov 30 '21 at 23:04
  • @glennjackman I'm not familiar with the 'use' so I will look that up. Worst case I'll just have to modify my script so the parts that are for the groupUser will be a part of that users bash and will just have to suck it up and switch user accounts. – edjm Nov 30 '21 at 23:05
  • "use" is just a verb. "[tag:expect]" is what you might want to look up. – glenn jackman Dec 01 '21 at 01:04

0 Answers0