-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dracut-install cleanup #1796
dracut-install cleanup #1796
Conversation
63c7bf4
to
fe30eb0
Compare
src/install/dracut-install.c
Outdated
|
||
realpath_p = realpath(target_dir_p, NULL); | ||
if (realpath_p == NULL) { | ||
if (realpath(target_dir_p, relative_from) == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relative_from
as a temporary buffer to build realfrom
and realtarget
is fine, but its name is confusing. Maybe rename it to buf
or whatever? (comments below will need update in this case)
This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions. |
bad bot |
rebased |
src/install/dracut-install.c
Outdated
if (vfork() == 0) { | ||
dup2(fds[1], 1); | ||
dup2(fds[1], 2); | ||
execlp(ldd, ldd, fullsrcpath, (char *)NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break at least the "command not found" case, that will be considered successful (ret = 0
). However current popen()
code is also broken for non-english locales: sh
and ldd
output is internationalized and error messages do not match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this actually depends on the "command not found" bash output? sh -c
obviously outputs sh: 1: ldd: not found
, like it has for the past 30+ years. Wild. Added a "command not found" write to compensate.
The latter fixed by setting LC_ALL=C
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if checking wstatus could simplify things, like:
pid_t pid = fork();
if (pid == 0) {
dup2(fds[1], 1);
dup2(fds[1], 2);
putenv("LC_ALL=C");
execlp(ldd, ldd, fullsrcpath, (char *)NULL);
_exit(EXIT_FAILURE);
}
close(fds[1]);
while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) {
ret = 1;
break;
}
}
if (ret != 0) {
log_error("ERROR: failed to run '%s %s'", ldd, fullsrcpath);
return 1;
}
while (getline(&buf, &linesize, fptr) >= 0) {
...
(dropped err
)
Then clean up strstr()
calls below, removing the ones which correspond to unclean exit codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, there's three strings
"you do not have execution permission"
"unable to find sysroot"
"command not found"
The last one is obviously from bash, but (my) ldd (or ld.so) doesn't contain the other two. Are they all foldable together to $? != 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"you do not have execution permission" is generated by ldd
itself:
$ cp -p /usr/bin/true .
$ chmod -x true
$ LANG=C ldd true
ldd: warning: you do not have execution permission for `./true'
linux-vdso.so.1 (0x00007ffe08fd3000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe9f8a28000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe9f8c38000)
The exit code is 0... maybe ignore the warning? Dunno.
"unable to find sysroot" appears to come from https://github.com/crosstool-ng/crosstool-ng/blob/8fa98eeeff9bc53478d97ef722f366fea151ae64/scripts/xldd.in#L170 , so it must stay I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oddly, I don't see it on bullseye:
$ cp /bin/rm .
$ chmod -x rm
$ ldd ./rm
linux-vdso.so.1 (0x00007ffdef1d4000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f70fc5fb000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f70fc42e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f70fc2ea000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f70fc125000)
libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f70fc08d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f70fc087000)
/lib64/ld-linux-x86-64.so.2 (0x00007f70fc649000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f70fc06b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f70fc049000)
And grepping through ldd there's a "you have no read" but no "you have no execute".
Would love a hard opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am on Fedora 36 here btw. "you do not have execution permission" was added in
hence it must stay too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, if the noexec
case makes ldd
exit code != 0, then drop it. Needs testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this is a Debian patch, all/local-ldd.diff
:
- test -x "$file" || echo 'ldd:' $"\
-warning: you do not have execution permission for" "\`$file'" >&2
Applied != 0 => ret += 1; retained all except for "command not found"
60a6afc
to
e5d9df8
Compare
src/install/dracut-install.c
Outdated
wait(&err); | ||
while (waitpid(ldd_pid, &err, 0) == -1) { | ||
if (errno != EINTR) { | ||
if (err != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitpid()
returns the terminated pid (> 0) when sucessfull, but its exit status still can be abnormal: non-zero exit code, killed by signal... hence err != 0
check and error message print need to be outside the loop[*]. If waitpid() < 0
and errno != EINTR
things are broken and we must assume everything failed: err
in this case cannot be trusted (I think most implementations do not change it, not sure). Set it to anything non-zero.
write(2, "command not found", ...)
is not needed. Also, to print meaningful exit codes/signals in the error message, it would need WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, macros. Overkill in my opinion.
[*] cp()
function (normal_copy
label) is buggy in this regard too, because those log_error()
will not run in case of normal errors, when waitpid()
succeeds (missing cp
binary, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was clearly in no state to be writing this last night, because this is an obvious error; I've fixed this and cp.
7943cd0
to
bb96d3d
Compare
LGTM |
Can this go in to get more testing? |
This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions. |
bad bot |
This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions. |
ping |
pong. looks fine on my end? |
This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions. |
so true, bestie |
Personally, I would prefer having #1987 around to help out for these reviews. Not sure if someone there is a way to do a run just for this PR. |
unresolved conversation and un-requested re-reviews ( @marcosfrm acked in comment section not in the review process ) has the tendency to get pr ignored from those of us that are quite busy anyways let's not merge this until in 059 milestone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything I was able to check and test went well, so let's merge this.
Changes
See individual commit messages; draft because on top of #1794