support systems without setresugid
This commit is contained in:
		
							
								
								
									
										12
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								main.c
									
									
									
									
									
								
							| @@ -13,10 +13,15 @@ | |||||||
| #include <locale.h> | #include <locale.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.61 2006/11/12 14:58:15 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/main.c,v 1.62 2006/11/16 13:35:07 tg Exp $"); | ||||||
|  |  | ||||||
| extern char **environ; | extern char **environ; | ||||||
|  |  | ||||||
|  | #if !HAVE_SETRESUGID | ||||||
|  | extern uid_t kshuid; | ||||||
|  | extern gid_t kshgid, kshegid; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static void reclaim(void); | static void reclaim(void); | ||||||
| static void remove_temps(struct temp *); | static void remove_temps(struct temp *); | ||||||
|  |  | ||||||
| @@ -220,7 +225,12 @@ main(int argc, char *argv[]) | |||||||
| 		setstr(vp, safe_prompt, KSH_RETURN_ERROR); | 		setstr(vp, safe_prompt, KSH_RETURN_ERROR); | ||||||
|  |  | ||||||
| 	/* Set this before parsing arguments */ | 	/* Set this before parsing arguments */ | ||||||
|  | #if HAVE_SETRESUGID | ||||||
| 	Flag(FPRIVILEGED) = getuid() != ksheuid || getgid() != getegid(); | 	Flag(FPRIVILEGED) = getuid() != ksheuid || getgid() != getegid(); | ||||||
|  | #else | ||||||
|  | 	Flag(FPRIVILEGED) = (kshuid = getuid()) != ksheuid || | ||||||
|  | 	    (kshgid = getgid()) != (kshegid = getegid()); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	/* this to note if monitor is set on command line (see below) */ | 	/* this to note if monitor is set on command line (see below) */ | ||||||
| 	Flag(FMONITOR) = 127; | 	Flag(FMONITOR) = 127; | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								misc.c
									
									
									
									
									
								
							| @@ -6,7 +6,7 @@ | |||||||
| #include <grp.h> | #include <grp.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.42 2006/11/12 14:58:15 tg Exp $\t" | __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.43 2006/11/16 13:35:07 tg Exp $\t" | ||||||
| 	MKSH_SH_H_ID); | 	MKSH_SH_H_ID); | ||||||
|  |  | ||||||
| #undef USE_CHVT | #undef USE_CHVT | ||||||
| @@ -16,6 +16,11 @@ __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.42 2006/11/12 14:58:15 tg Exp $\t" | |||||||
|  |  | ||||||
| unsigned char chtypes[UCHAR_MAX + 1];	/* type bits for unsigned char */ | unsigned char chtypes[UCHAR_MAX + 1];	/* type bits for unsigned char */ | ||||||
|  |  | ||||||
|  | #if !HAVE_SETRESUGID | ||||||
|  | uid_t kshuid; | ||||||
|  | gid_t kshgid, kshegid; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static int do_gmatch(const unsigned char *, const unsigned char *, | static int do_gmatch(const unsigned char *, const unsigned char *, | ||||||
|     const unsigned char *, const unsigned char *); |     const unsigned char *, const unsigned char *); | ||||||
| static const unsigned char *cclass(const unsigned char *, int); | static const unsigned char *cclass(const unsigned char *, int); | ||||||
| @@ -251,7 +256,10 @@ change_flag(enum sh_flag f, | |||||||
| #endif | #endif | ||||||
| 		setresuid(ksheuid, ksheuid, ksheuid); | 		setresuid(ksheuid, ksheuid, ksheuid); | ||||||
| #else | #else | ||||||
| #error setresid/setresgid required at the moment | 		seteuid(ksheuid = kshuid = getuid()); | ||||||
|  | 		setuid(ksheuid); | ||||||
|  | 		setegid(kshegid = kshgid = getgid()); | ||||||
|  | 		setgid(kshegid); | ||||||
| #endif | #endif | ||||||
| 	} else if (f == FPOSIX && newval) { | 	} else if (f == FPOSIX && newval) { | ||||||
| 		Flag(FBRACEEXPAND) = 0; | 		Flag(FBRACEEXPAND) = 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user