Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Substitute Commands Depending on User ID

Submitted by on September 9, 2010 – 2:44 pm One Comment

Here is a quick example of how to substitute system commands based on who tries to run them. A customer of mine has recently deployed a security audit application on his servers. The application has a few bugs that the vendor has not yet resolved.

For example, the security audit agent looks at the output of the “mount” command to see if any filesystems are mounted without the “nosuid” option. However, there is a bug in the audit tool and it fails to exclude certain filesystems where “nosuid” option should not be used.

Until the problem with the audit tool is fixed, we wanted to disable this particular test on per-server basis. This could not be done centrally from the audit application and had to be done locally on each client node.

The idea was simple: the audit tool runs under “bigbro” username and we wanted the “mount” command to behave differently for that user.

Step one was to move /bin/mount to /bin/mount_orig. Then we created a new /bin/mount containing the following shell script:

#!/bin/sh
if [ `id -un` == "bigbro" ]
then
     echo ""
else
     /bin/mount_orig $*
fi

Then we just chmod 755 /bin/mount and “bigbro” was no longer able to annoy us with false non-compliance reports. Very unprofessional, I know, but what’cha gonna do?

Print Friendly, PDF & Email

One Comment »

  • kevindiking67verizonnet says:

    I wanna create an Application that will help other I touch users access my site and take full advantage of it like other applications such as facebook, myspace, I.M., Textfree and etc If someone could tell me that would be great

Leave a Reply

%d bloggers like this: