Thread View: gnu.utils.bug
2 messages
2 total messages
Started by Neal Becker
Tue, 21 Jul 1992 15:07
Enhancement for gnu tar/NFS
Author: Neal Becker
Date: Tue, 21 Jul 1992 15:07
Date: Tue, 21 Jul 1992 15:07
148 lines
3930 bytes
3930 bytes
If you are stuck with NFS/root access problems ( like on HPUX
machines ) you may find this patch useful. This patch introduces the
same kind of kludge as the chdir option (-C) to do seteuid. For some
reason I've forgotten, I called this (-E). I use this to read user's
files using NFS. Use it like this:
tar .... -E user1 ~user1 -Euser2 ~user2 ...
Thus, we backup user1's files *as* user1, ...etc. Neat, huh?
----------------------------------------------------------
diff -c tar.c.old tar-1.10/tar.c
*** tar.c.old Tue Jul 21 09:40:48 1992
--- tar-1.10/tar.c Mon Jul 20 16:07:36 1992
***************
*** 309,315 ****
/* Parse options */
while ((c = getoldopt(argc, argv,
! "-01234567Ab:BcC:df:F:g:GhikK:lL:mMN:oOpPrRsStT:uvV:wWxX:zZ",
long_options, &ind)) != EOF) {
switch (c) {
case 0: /* long options that set a single flag */
--- 309,315 ----
/* Parse options */
while ((c = getoldopt(argc, argv,
! "-01234567Ab:BcC:df:E:F:g:GhikK:lL:mMN:oOpPrRsStT:uvV:wWxX:zZ",
long_options, &ind)) != EOF) {
switch (c) {
case 0: /* long options that set a single flag */
***************
*** 322,327 ****
--- 322,331 ----
name_add("-C");
name_add(optarg);
break;
+ case 'E':
+ name_add("-E");
+ name_add(optarg);
+ break;
case 10: /* preserve */
f_use_protection = f_sorted_names = 1;
break;
***************
*** 735,740 ****
--- 739,746 ----
register char *p;
register char *q = 0;
register char *q2 = 0;
+ register char *q3 = 0;
+ register char *q4 = 0;
extern char *un_quote_string();
***************
*** 770,775 ****
--- 776,793 ----
}
/* End of JF quick -C hack */
+ if(c && !q3 && p[0]=='-' && p[1]=='E' && p[2]=='\0') {
+ q3=p;
+ goto tryagain;
+ }
+ if(q3) {
+ if(SetUid(p)<0)
+ msg_perror("Can't setuid to %s",p);
+ q3=0;
+ goto tryagain;
+ }
+ /* End of JF quick -C hack */
+
if(f_exclude && check_exclude(p))
goto tryagain;
return un_quote_string(p);
***************
*** 799,805 ****
q2 = 0;
goto tryagain;
}
!
if(f_exclude && check_exclude(p))
goto tryagain;
return un_quote_string(p);
--- 817,832 ----
q2 = 0;
goto tryagain;
}
! if(c && !q4 && p[0]=='-' && p[1]=='E' && p[2]=='\0') {
! q4=p;
! goto tryagain;
! }
! if(q4) {
! if(SetUid(p)<0)
! msg_perror("Can't setuid to %s",p);
! q4=0;
! goto tryagain;
! }
if(f_exclude && check_exclude(p))
goto tryagain;
return un_quote_string(p);
***************
*** 1312,1314 ****
--- 1339,1381 ----
}
return 0;
}
+
+ #include <pwd.h>
+
+ static int OriginalRUid = -1;
+ static int OriginalEUid = -1;
+
+ static int SetUid( name )
+ char* name;
+ {
+ struct passwd* p;
+ int uid;
+
+ if( OriginalRUid == -1 ) {
+ OriginalRUid = getuid();
+ OriginalEUid = geteuid();
+ }
+ else {
+ if( setreuid( OriginalRUid, OriginalEUid ) != 0 ) {
+ fprintf( stderr, "Can't reset uid\n" );
+ return -1;
+ }
+ }
+ p = getpwnam( name );
+
+ if( p == NULL ) return -1;
+ else {
+ fprintf( stderr, "setuid %s(%d)\n", name, p->pw_uid );
+ return setreuid( p->pw_uid, p->pw_uid );
+ }
+ }
+
+ #ifdef __hpux
+
+ static int setreuid( ruid, euid )
+ uid_t ruid, euid;
+ {
+ return setresuid( ruid, euid, -1 );
+ }
+
+ #endif
Enhancement for gnu tar/NFS
Author: Michael I Bushnell
Date: Fri, 24 Jul 1992 03:32
Date: Fri, 24 Jul 1992 03:32
20 lines
1368 bytes
1368 bytes
Resent-Date: Tue, 21 Jul 92 11:07 EDT Date: Tue, 21 Jul 92 11:07 EDT From: neal@ctd.comsat.com (Neal Becker) Sender: gnulists@ai.mit.edu Resent-From: bug-gnu-utils-request@prep.ai.mit.edu If you are stuck with NFS/root access problems ( like on HPUX machines ) you may find this patch useful. This patch introduces the same kind of kludge as the chdir option (-C) to do seteuid. For some reason I've forgotten, I called this (-E). I use this to read user's files using NFS. Use it like this: tar .... -E user1 ~user1 -Euser2 ~user2 ... Thus, we backup user1's files *as* user1, ...etc. Neat, huh? I would advise people *not* to do this. It is much better to either fix broken NFS implementations, or to run tar on the NFS server. The latter option will also make your backups run MUCH faster. The backup stripts distributed with GNU tar do this for you.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads