dracut: only copy xattr, if root
otherwise cp complains a lot about not being able to copy xattrsmaster
							parent
							
								
									83a6d6f928
								
							
						
					
					
						commit
						076fcd1652
					
				|  | @ -19,7 +19,11 @@ | ||||||
| # | # | ||||||
| export LC_MESSAGES=C | export LC_MESSAGES=C | ||||||
|  |  | ||||||
| export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr" | if [[ "$UID" = "0" ]]; then | ||||||
|  |     export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr" | ||||||
|  | else | ||||||
|  |     export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr" | ||||||
|  | fi | ||||||
|  |  | ||||||
| # is_func <command> | # is_func <command> | ||||||
| # Check whether $1 is a function. | # Check whether $1 is a function. | ||||||
|  |  | ||||||
|  | @ -275,8 +275,13 @@ static int cp(const char *src, const char *dst) | ||||||
|                 if (ret == 0) { |                 if (ret == 0) { | ||||||
|                         struct timeval tv[2]; |                         struct timeval tv[2]; | ||||||
|                         if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0) |                         if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0) | ||||||
|                                 if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0) |                                 if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0) { | ||||||
|  |                                         if (geteuid() == 0) | ||||||
|                                                 log_error("Failed to chown %s: %m", dst); |                                                 log_error("Failed to chown %s: %m", dst); | ||||||
|  |                                         else | ||||||
|  |                                                 log_info("Failed to chown %s: %m", dst); | ||||||
|  |                                 } | ||||||
|  |  | ||||||
|                         tv[0].tv_sec = sb.st_atime; |                         tv[0].tv_sec = sb.st_atime; | ||||||
|                         tv[0].tv_usec = 0; |                         tv[0].tv_usec = 0; | ||||||
|                         tv[1].tv_sec = sb.st_mtime; |                         tv[1].tv_sec = sb.st_mtime; | ||||||
|  | @ -295,7 +300,11 @@ static int cp(const char *src, const char *dst) | ||||||
|  normal_copy: |  normal_copy: | ||||||
|         pid = fork(); |         pid = fork(); | ||||||
|         if (pid == 0) { |         if (pid == 0) { | ||||||
|                 execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps,xattr", "-fL", src, dst, |                 if (geteuid() == 0) | ||||||
|  |                         execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst, | ||||||
|  |                                NULL); | ||||||
|  |                 else | ||||||
|  |                         execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst, | ||||||
|                                NULL); |                                NULL); | ||||||
|                 _exit(EXIT_FAILURE); |                 _exit(EXIT_FAILURE); | ||||||
|         } |         } | ||||||
|  | @ -303,7 +312,11 @@ static int cp(const char *src, const char *dst) | ||||||
|         while (waitpid(pid, &ret, 0) < 0) { |         while (waitpid(pid, &ret, 0) < 0) { | ||||||
|                 if (errno != EINTR) { |                 if (errno != EINTR) { | ||||||
|                         ret = -1; |                         ret = -1; | ||||||
|                         log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr -fL %s %s", src, |                         if (geteuid() == 0) | ||||||
|  |                                 log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src, | ||||||
|  |                                           dst); | ||||||
|  |                         else | ||||||
|  |                                 log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src, | ||||||
|                                           dst); |                                           dst); | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Harald Hoyer
						Harald Hoyer