mirror of
				https://github.com/fspc/gbootroot.git
				synced 2025-10-30 23:25:36 -04:00 
			
		
		
		
	This solves a tough to discover bug. When root objcopy the permissions were
preserved for libraries, but this wasn't the case for non-root users. The part which did preserve permissions with chmod didn't allow non-root users, but with genext2fs this isn't a problem, though chown is. Anyways, when ld or libc aren't 0755 basically the kernel can't find init. Problem solved.
This commit is contained in:
		
							parent
							
								
									3015d7f233
								
							
						
					
					
						commit
						caca3cae38
					
				| @ -1179,6 +1179,9 @@ sub copy_strip_file { | |||||||
|        $strip_lib, $strip_bin, $strip_module) = @_; |        $strip_lib, $strip_bin, $strip_module) = @_; | ||||||
|     my $error; |     my $error; | ||||||
| 
 | 
 | ||||||
|  |     # Need to know whether genext2fs is being used | ||||||
|  |     my $fs_type = (split(/\s/,$main::makefs))[0]; | ||||||
|  | 
 | ||||||
|     if ($strippable{$from}) { |     if ($strippable{$from}) { | ||||||
| 
 | 
 | ||||||
|         #  Copy it stripped |         #  Copy it stripped | ||||||
| @ -1187,18 +1190,18 @@ sub copy_strip_file { | |||||||
| 		#  It's a library | 		#  It's a library | ||||||
| 		if ($strip_objfiles == 1) { | 		if ($strip_objfiles == 1) { | ||||||
| 		    info(1, "Copy/stripping library $from to $to\n"); | 		    info(1, "Copy/stripping library $from to $to\n"); | ||||||
| 		    sys("$objcopy --strip-all $from $to"); | 		    sys("$objcopy --strip-all -p $from $to"); | ||||||
| 		} | 		} | ||||||
| 		elsif ($strip_objfiles == 0) { | 		elsif ($strip_objfiles == 0) { | ||||||
| 		    info(1, "Copy/stripping library $from to $to\n"); | 		    info(1, "Copy/stripping library $from to $to\n"); | ||||||
| 		    sys("$objcopy --strip-debug $from $to"); | 		    sys("$objcopy --strip-debug -p $from $to"); | ||||||
| 		} | 		} | ||||||
| 	    }    | 	    }    | ||||||
| 	} | 	} | ||||||
| 	if ($strip_module) { | 	if ($strip_module) { | ||||||
| 	    if (defined($is_module{$from})) { | 	    if (defined($is_module{$from})) { | ||||||
| 		info(1, "Copy/stripping module $from to $to\n"); | 		info(1, "Copy/stripping module $from to $to\n"); | ||||||
| 		sys("$objcopy --strip-debug $from $to"); | 		sys("$objcopy --strip-debug -p $from $to"); | ||||||
| 	    } | 	    } | ||||||
| 	}  | 	}  | ||||||
| 	if ($strip_bin) { | 	if ($strip_bin) { | ||||||
| @ -1206,7 +1209,7 @@ sub copy_strip_file { | |||||||
| 		!defined($lib_needed_by{$from})) { | 		!defined($lib_needed_by{$from})) { | ||||||
| 		#  It's a binary executable | 		#  It's a binary executable | ||||||
| 		info(1, "Copy/stripping binary executable $from to $to\n"); | 		info(1, "Copy/stripping binary executable $from to $to\n"); | ||||||
| 		sys("$objcopy --strip-all $from $to"); | 		sys("$objcopy --strip-all -p $from $to"); | ||||||
| 	    } | 	    } | ||||||
| 	} | 	} | ||||||
| 	else { # fallback just in case | 	else { # fallback just in case | ||||||
| @ -1231,21 +1234,26 @@ sub copy_strip_file { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	# Copy file perms and owner | 	# Copy file perms and owner | ||||||
| 	## non-root users will experience problems here so this is | 	## If non-root users are using genext2fs then it is safe to | ||||||
| 	## skipped. --freesource | 	## chmod, but not to chown. --freesource | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	my($mode, $uid, $gid); | 	my($mode, $uid, $gid); | ||||||
| 	(undef, undef, $mode, undef, $uid, $gid) = stat $from; | 	(undef, undef, $mode, undef, $uid, $gid) = stat $from; | ||||||
| 	my $from_base = basename($from); | 	my $from_base = basename($from); | ||||||
| 
 | 
 | ||||||
| 	if ( $> == 0 ) { | 	if ( $> == 0 || $fs_type eq "genext2fs" ) { | ||||||
| 	    chown($uid, $gid, $to) or ($error =  | 	     | ||||||
| 				       error("chown: $! \($from_base\)\n")); | 	    if ( $> == 0 ) { | ||||||
| 	    return "ERROR"if $error && $error eq "ERROR"; | 		chown($uid, $gid, $to) or ($error =  | ||||||
|  | 			 error("chown: $! \($from_base\)\n")); | ||||||
|  | 		return "ERROR"if $error && $error eq "ERROR"; | ||||||
|  | 	    } | ||||||
|  | 
 | ||||||
| 	    chmod($mode, $to)      or ($error =  | 	    chmod($mode, $to)      or ($error =  | ||||||
| 				       error("chmod: $! \($from_base\)\n")); | 				       error("chmod: $! \($from_base\)\n")); | ||||||
| 	    return "ERROR"if $error && $error eq "ERROR"; | 	    return "ERROR"if $error && $error eq "ERROR"; | ||||||
|  | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	## else { | 	## else { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user