Discussion:
[sudo-users] sudo & cd command from rksh
(too old to reply)
paul harrison
2006-07-27 16:39:16 UTC
Permalink
Hi
I want to allow a user to be able to send test scripts and reports to another
directory outside of their login, and
don't want to give them full account capbilities so as to prevent them from
cd'ing outside of their directory, so I set up the user with rksh(restricted
shell), but apparently this also prevents even sudo from executing the cd
command.
I was trying to

1.. Create a sudo account permission for the user to run 2 shell scripts
as another user
2. Create shell scripts to copy the files to the appropriate directories:

#!/bin/sh
# sql copy script
sudo cd sql(subdirectory within local user)
chmod 777 *
sudo cd /test/sqlrpts /sql (directory path outside of user login)
sudo cp / local subdirectory /sql/*

any help is appreciated. Thanks.
P.
____________________________________________________________
sudo-users mailing list <sudo-***@sudo.ws>
For list information, options, or to unsubscribe, visit:
http://www.sudo.ws/mailman/listinfo/sudo-users
Todd C. Miller
2006-07-27 17:03:44 UTC
Permalink
You cannot use the "cd" command with sudo since "cd" is a construct
of the shell. While some OSes include a "cd" command it can't
really do anything since it is not possible to change the current
working dir of the parent process. Basically, it will change the
current working directory and then exit, leaving you right where
you started.

What you probably want to do is to write a simple shell script
that does the cd and the commands you need done and give the
user sudo access to that script.

- todd
____________________________________________________________
sudo-users mailing list <sudo-***@sudo.ws>
For list information, options, or to unsubscribe, visit:
http://www.sudo.ws/mailman/listinfo/sudo-users
r***@reedmedia.net
2006-07-27 18:51:58 UTC
Permalink
Post by paul harrison
sudo cd sql(subdirectory within local user)
chmod 777 *
sudo cd /test/sqlrpts /sql (directory path outside of user login)
sudo cp / local subdirectory /sql/*
Don't use the "sudo cd" lines. Just do the chmod and cp commands using the
paths.

(You have some basic problems above too, which you may want to discuss
with your local users group.)
____________________________________________________________
sudo-users mailing list <sudo-***@sudo.ws>
For list information, options, or to unsubscribe, visit:
http://www.sudo.ws/mailman/listinfo/sudo-users

Loading...