04-13-2004
Deleting root files from another user
I want to delete some files and directories owned by root from another different user in HP-UX 10.20.
The list of files looks like:
(user test)
bash-2.03$ ls -alrt
total 20
-rw-r--r-- 1 root root 55 Aug 27 2003 _index_jsp_2.dat
-rw-r--r-- 1 root root 4100 Aug 27 2003 _index.class
drwxr-xr-x 3 root other 512 Jan 22 13:33 ..
drwxr-xr-x 2 root root 512 Mar 5 10:53 error_5F_pages
drwxr-xr-x 4 root other 512 Mar 5 10:54 .
drwxr-xr-x 5 root root 512 Apr 12 19:24 jsp
I have programmed and compiled a C source as root that executes a shell and have set the s-uid-gid bit in order to execute them with the efective user root.
The C source sais:
/***********************************************/
#include <stdio.h>
#include <unistd.h>
int main(){
char *env[]={"PATH=/bin:/usr/bin",NULL};
char prog[]="/appli/test/shtest";
if (access(prog,X_OK)){
fprintf(stderr,"ERROR: %s \n",prog);
return(1);
}
system(prog);
perror("test");
return(1);
}
/***********************************************/
The shell (/appli/test/shtest):
rm -r /appli/test/www/*
-rw-r--r-- 1 root other 43 Apr 12 11:25 makefile
-rw-r--r-- 1 root other 328 Apr 12 11:47 test.c
-rwsrwsrwt 1 root other 6808 Apr 12 11:51 test2
-rwxrwxrwx 1 root other 74 Apr 13 08:39 shtest
The binary (test2) tries to execute shtest which is the shell that tries to remove these files.
When I execute it as "test" the system message says:
rm: /appli/test/www/_index.class: override protection 644 (yes/no)? yes
rm: /appli/test/www/_index.class not removed: Permission denied
The problem is that the directory where the list of files are stored is owned by root and the user isn't allowed for writing in it:
drwxr-xr-x 4 root other 512 Mar 5 10:54 www
It's not possible to change this permissons because they are automatically generated and we don't want to use a cron task which changes these permissons because there are thousands of files of this kind that we want to delete.
Do you know if I can remove these files and directories with a non-root (nor system...) user?
Thanks in advance
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi all,
I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies
2. Shell Programming and Scripting
ok i am setting up a script to run daily using crontab. This script will search the root filesystem and delete any and all core files. I have set up this script
The only problem i get with this script is it searches for directories and attempts to delete them. Since i have probably... (7 Replies)
Discussion started by: rgfirefly24
7 Replies
3. UNIX for Dummies Questions & Answers
hi, I have two users, let us call them A and B.
I do as User A
touch tmpfile
chmod 700 tmpfile
Now as User B I do rm tmpfile - and it allows me to do it (after prompting me)...why?
If I had done chmod 777 tmpfile, then sure User B should be able to delete it, but I did chmod 700... (3 Replies)
Discussion started by: JamesByars
3 Replies
4. UNIX for Dummies Questions & Answers
hi
i am new to unix and i have abig task. i have to \run particular commands having root privileges from a non root user. i know sudo is one of the way but i need sum other approach kindly help
Thanks (5 Replies)
Discussion started by: suryashikha
5 Replies
5. AIX
Hi
I'm logged in to an AIX box now and we need to do an audit on this box.
cbssapr01:# pwd
/
Which command will show all the files and directories owned by root user with permissions as 777 ? (8 Replies)
Discussion started by: newtoaixos
8 Replies
6. UNIX for Dummies Questions & Answers
I've been through many threads before i decide to create a separate thread.
I can't really find the solution to my (simple) problem.
Here's what I'm trying to achieve:
As "canar" user I want to run a command, let's say "/opt/ocaml/bin/ocaml" as "duck" user.
The only to achieve this is to... (1 Reply)
Discussion started by: canar
1 Replies
7. UNIX for Advanced & Expert Users
Hi!! one strange problem occurred with my RHEL 5 box.
i'm having logs folder with ownership of non-root user. Created some files with root user under logs folder.
here is the scene:
-rw-r----- 1 root root 1048227 Feb 28 12:34 SystemOut_13.02.28_12.34.10.log
-rw-r----- 1 root root ... (6 Replies)
Discussion started by: sukhdip
6 Replies
8. Shell Programming and Scripting
Currently in my system Red Hat is installed. And Many user connect to my machine via SSH Techia Terminal.
I want to give some users a root level access.
Can anyone please help me how to make it possible. I too searched on the Google but didn't find the correct way
Regards
ADI (4 Replies)
Discussion started by: adisky123
4 Replies
9. UNIX for Dummies Questions & Answers
Whenever i switch from root to another user, by doing su - user, it takes me to home directory of user. This is very annoying as i want to be in same dir to run different commands as root sometimes and sometimes as normal user.
How to fix this? (1 Reply)
Discussion started by: syncmaster
1 Replies
10. UNIX for Dummies Questions & Answers
Hi,
when I installed debian 8, all files are created and owned by root, when I add new user, for example marco, he can't create directory or change files created by root. I tried with ftp, permission denied.
so, I am interested how to grant to user marco ownership of all files in the system so... (5 Replies)
Discussion started by: alanford
5 Replies
LEARN ABOUT OSX
dsenableroot
dsenableroot(8) BSD System Manager's Manual dsenableroot(8)
NAME
dsenableroot -- enables or disables the root account.
SYNOPSIS
dsenableroot [-d] [-u username] [-p password] [-r rootPassword]
DESCRIPTION
dsenableroot sets the password for the root account if enabling the root user account. Otherwise, if disable [-d] is chosen, the root
account passwords are removed and the root user is disabled.
A list of flags and their descriptions:
-u username
Username of a user that has administrative privileges on this computer.
-p password
Password to use in conjunction with the specified username. If this is not specified, you will be prompted for entry.
-r rootPassword
Password to be used for the root account. If this is not specified for enabling, you will be prompted for entry.
EXAMPLES
-dsenableroot
Your username will be used and you will be queried for both your password and the new root password to be set to enable the root
account.
-dsenableroot -d
Your username will be used and you will be queried for only your password to disable the root account.
-dsenableroot -u username -p userpassword -r rootpassword
The supplied arguments will be used to enable the root account.
-dsenableroot -d -u username -p userpassword
The supplied arguments will be used to disable the root account.
Mac OS August 08 2003 Mac OS