Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm trying to set up an alias that pipes incoming mail for a command in Postfix. So I have something like this in my /etc/aliases:
myuser: "|/usr/bin/command --parameter1 --parameter2"
The problem is that Postfix executes /usr/bin/command as user nobody:nogroup. According to this description it can be changed, but not for a single alias. So the question is how to set the user for a certain alias? Setting nobody:nogroup for a directory /usr/bin/command should operate is not an option.
Replace /usr/bin/command with /usr/bin/sudo -u <user> /usr/bin/command and configure sudo to allow nobody to execute this command.
[EDIT] There are two solutions for your problem:
Make all necessary files read/writable for nobody:nogroup
Change the user (either with a suid script or su/sudo).
If you don't like either, then there is no solution for your problem. You can't do it in aliases(5) because the format doesn't support this (other programs read this file as well, so postfix can't change the syntax).
You could use default_privs but that would change the user for all external commands and you don't want that (huge security risk).
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I hope that you can help me with the following problem: I want to implement a script that requires that $PATH variables has missing . value changes in it.
The point of the script is to find requested files and copy them to parent directory. I can do this using -execdir, but the problem is that . is defined in the $PATH.
Can you please tell me how can I provide a temporary replacement for the $PATH variable that can be valid only for the script execution.
Thanks
The shell allows you to set environment variables of an executable by passing them to the invocation. Like this:
PATH="/foo/bar" program
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Now I know I can edit bash_logout to execute commands once the user types exit, but only for a specific user by editing their bash_logout in their home directory. But how do I edit this for all users?
bash doesn't recognize a system-wide logout script. The best you can do is create a world-readable file like /etc/bash_logout, and recommend that users add . /etc/bash_logout to their personal ~/.bash_logout files.
The only system-wide configuration file bash recognizes is /etc/profile for login shells. You could add
trap 'on_logout' EXIT
(where on_logout is the name of a function you define that contains the desired log-out code) to this file and hope users don't reset the handler. (Technically, /etc/profile is shared amongst all POSIX-compatible shells, so don't put any bash-specific code in such a handler.)
What chepner said above .... if you wanted to be a BOFH you could create a .bash_logout for each user fairly easily ...
Variations based on your OS/Distro may (will?) apply ... assuming all ordinary users exist locally (you didn't mention LDAP) and have UID's in the range [1000...50000] ...
# iterate over all user accounts that are likely to be people with awk,
# print their home, loop over those homes and copy the logout file into place.
awk -F: '$3 >999 && $3 < 50000 { print $6}' /etc/passwd | while read home
do
cp /path/to/your/logout-script $home/.bash_logout
# if you want to be **reallY** nasty uncomment the next two lines.
# that will stop users from deleting the file.
# chown root $home/.bash_logout
# chattr +i $home/.bash_logout
done
If you ran that as root everyone on the system (be careful, see assumption above, make sure no system users get hit ... ) would get your desired logout file.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I created a few .sh files and put them under one of the directories under $PATH. Unfortunately every time I start a new session I have to source them if I want to use them. I did a google search and couldn't really find what I am looking for to not having to source these files.
I guess I can place a source all command at ~/.bashrc but there should be a way to get this done in a simple way.
Thanks
Let's say all of your scripts are under the ~/.functions directory. Put this in your $HOME/.bashrc:
for file in ~/.functions/*
do
. $file
done
This will source in all files in the ~/.functions directory whenever you start a new shell.
Sourcing all commands in .bashrc is the simple way.
You may want a sophisticated way of sourcing your start scripts by creating a specific directory, say ~/.start_scripts, where you put all your commands, and write a loop in your .bashrc that sources whatever executable is in this directory. That way, you no longer have to edit .bashrc each time a new command is put in the .start_scripts directory.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I don't have .bashrc file, I want to create one but how? And what does a basic .bashrc file contains? I am on Linux Mint 12
I want to have a .bashrc file, because i have created a folder for virtualenv and I want to load virtualenvwrapper
Why do you want one if you don't know what to put in there? You only need a .bashrc (or .profile or .bash_profile) if you actually have something you want to execute in every shell (or login shell).
But you can basically put any bash commands in those files.
A .bashrc file contains whatever default settings you want to use when you are using bash. If you don't have any particular preferences then leave it blank for now.
Typical contents of a .bashrc file includes aliases of commands you find yourself using a lot.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
When you use the up key in a Linux terminal, you can use previous commands again. Great feature. However, I started logging mysql into mysql with the sensitive details in the command.
How can I delete that history permanently?
You can clear your bash history like this:
history -cw
If you use bash, then the terminal history is saved in a file called .bash_history. Delete it, and history will be gone.
However, for MySQL the better approach is not to enter the password in the command line. If you just specify the -p option, without a value, then you will be prompted for the password and it won't be logged.
Another option, if you don't want to enter your password every time, is to store it in a my.cnf file. Create a file named ~/.my.cnf with something like:
[client]
user = <username>
password = <password>
Make sure to change the file permissions so that only you can read the file.
Of course, this way your password is still saved in a plaintext file in your home directory, just like it was previously saved in .bash_history.