Tarring problem.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tarring problem.
# 1  
Old 09-17-2011
Tarring problem.

We execute script to tarr files as normal user. Normal user doesn't have permission to append file to existing tarr file, since tarr files are owned by root user.

Even though script is creating tar file and is executed by normal user, It shows that tar file is created by root. I ran script for the date range 13-SEP-2011 and 14-SEP-2011. File tarring listed all files for the date 13-SEP-2011 first and tarred it and listed all the files belongs to 14-SEP-2011 then it tried to append these files to existing tarr file since both dates belong to the same week.Since normal user did not has enough permission to change the permission of the tarr file. Hence error occurred.

Example: Say, there are three files present in test directory namely a.txt, b.txt, c.txt and all are owned by root and belons to different week.
tar cvf TarFilename a.txt --> Working as expected.
The above script creates tarr file which is owned by root. since tarr fie retains propreties of file got tarred.
chmod 777 TarFilename
tar -rf TarFilename b.txt --> Failing since normal user does not has the permission to change the permission of tarr file.

We have two options now.
1. Change the owner of the directory where files need to be tarred.
2. Change the owner of the files(a.txt,b.txt etc) before sending it to our database.

Is there any way that we can achive this apart from above cases. please let me know.

Please let me know if need any details.

Thanks and Regards
Nagaraja

Last edited by Nagaraja Akkiva; 09-19-2011 at 08:35 AM..
# 2  
Old 09-17-2011
You can confiure sudoers to do the job.

Code:
sudo tar -rf TarFileName b.txt

The above command will run with root permissions.

You will have to add the following line in the /etc/sudoers file
Code:
normal_user ALL=NOPASSWD : /usr/bin/tar

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 09-18-2011
Allowing tar to be run as root is a big security hole, I'd advise against that.

Funny thing is I can't get tar to change owner of .tar file as you describe. What OS are you running and can you supply output of:

Code:
tar --version
what `which tar`

This User Gave Thanks to Chubler_XL For This Post:
# 4  
Old 09-19-2011
Ahamed,

Thanks for your answer. I will check this option.

Chubler,

Code:
tar -V

gives below results.

Code:
 
tar: option requires an argument -- V
Try `tar --help' for more information

Code:
what `which tar`

gives below output.


-bash: what: command not found

Code:
 which tar

gives output as below.


/bin/tar

Please let me know if it is helpful to you.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++
The version of the tarris 1.14. Typed man tar and at the end I got this version. In latest version
Code:
tar -V, what `which tar`

gives the version.

Last edited by Nagaraja Akkiva; 09-19-2011 at 08:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Tarring files to remote server

Hi, I need to tar some files in a directory to a remote server. I need to exclude some file from this directory and then tar it over. This is the command suggested by one article (tarring in the same server) : tar -zcvf /tmp/mybackup.tar.gz -X exclude.txt /home/me However it does not... (9 Replies)
Discussion started by: anaigini45
9 Replies

2. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

3. UNIX for Dummies Questions & Answers

Tarring files up to four days old

Hi I need help in tarring files up to four days old. I have been doing this: find . -mtime -4|xargs tar -cvf mar4.tar However, it seems like it's tarring everything but leaving those that are 4 days old and newer (which I want tarred and everything else not) ---------- Post updated at... (1 Reply)
Discussion started by: MIA651
1 Replies

4. IP Networking

Problem with forwarding emails (SPF problem)

Hi, This is rather a question from a "user" than from a sys admin, but I think this forum is apropriate for the question. I have an adress with automatic email forwarding and for some senders (two hietherto), emails are bouncing. This has really created a lot of problems those two time so I... (0 Replies)
Discussion started by: carwe
0 Replies

5. Shell Programming and Scripting

Bash Tarring not un Tarring correctly

HI All, Im encountering behaviour that is not correct for my requirements when I untar a file. Im using the below command to tar up files from various folders to the ARCHIVE folder as below... tar -cvf "$ARCHIVE_PATH"/"$dte_tar_filename" "$LOG_PATH" "$PROCESSED_PATH2" "$ERROR_PATH" ... (5 Replies)
Discussion started by: satnamx
5 Replies

6. AIX

user login problem & Files listing problem.

1) when user login to the server the session got colosed. How will resolve? 2) While firing the command ls -l we are not able to see the any files in the director. but over all view the file system using the command df -g it is showing 91% used. what will be the problem? Thanks in advance. (1 Reply)
Discussion started by: pernasivam
1 Replies

7. Shell Programming and Scripting

tarring/compressing files in Unix directory

hi guys, i'm totally new with Unix sripting and no idea how to do the scripting at all. My problem is that my boss asked me to do this: 1.) create a script that will tar or gzip the files in particular directory eg: i'm on my home directory and I need to tar/gzip the file in.. assuming... (1 Reply)
Discussion started by: montski
1 Replies

8. UNIX for Dummies Questions & Answers

tarring large no. of files

dears, I have a folder containing huge no. of files, some of them are created on AUG 16, AUG 17 and AUG 18, for example. All I want to do is tarring all the files created on a certain date, say AUG 18, in one tar file, only in one command line. So, how to feed all the files created on a certain... (4 Replies)
Discussion started by: marwan
4 Replies

9. UNIX for Dummies Questions & Answers

tarring and gzipping dump files

Say I want to transfer several dump files from a Solaris machine onto a Win2k machine for storage. It was suggested that I tar and gzip the dump files before doing so. Is it completely necessary to use both of these utilities, or is it sufficient to compress multiple dump files into one gzip... (4 Replies)
Discussion started by: PSC
4 Replies

10. UNIX for Dummies Questions & Answers

backup : files being modified while tarring

I would like to back up several directories weekly using a cronjob. I'm not experienced in UNIX, but I would start like this: tar -cvf backup.tar dir1 dir2 dir3 Now if a file is being modified in the process it will result in an error. How can I prevent this from happening and how can I... (5 Replies)
Discussion started by: jamesbond
5 Replies
Login or Register to Ask a Question