Run as another user: no password in tty but in X

Forum rules
Before you post please read how to get help
Post Reply
Arikania
Level 1
Level 1
Posts: 19
Joined: Tue Jan 10, 2017 9:32 pm
Location: The Netherlands
Contact:

Run as another user: no password in tty but in X

Post by Arikania » Wed Mar 15, 2017 12:53 pm

I want a directory where I can put scripts which my guests should be able to run without a password, but not be able to read.

I modified my /etc/sudoers file, adding the latter uncommented line, which was approved by visudo:

Code: Select all

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults	env_reset
Defaults	mail_badpass
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo	ALL=(ALL:ALL) ALL
guest   ALL=(replacing_user) /mnt/mydrive/scripts/dontpeek/*


# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
with guest having no permits in /mnt/mydrive/scripts/dontpeek/, which contains myprivatescript having permits -rwxrwxr-x, and being owned by replacing_user.

Then, in a directory that is in my path, I have this start up script, with rx permits for guest:

Code: Select all

#! /bin/bash

prog="/mnt/mydrive/scripts/dontpeek/myprivatescript"

if [ "$USER" == "guest" ]; then
  env Owner="replacing_user" sudo -u replacing_user "$prog" "$@"
else
  env Owner="$USER" "$prog" "$@"
fi
If I run the start up script from a guest tty screen, it works as it is supposed to. But if I run it from a terminal on a guest graphics login, it still asks for a password. And it won't start from my menu at all.

Why does this happen, and how do I get around this.


With kindest regards,
Image

Post Reply

Return to “Scripts & Bash”