Skip to content
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

Can't cd to (unreachable)/: No such file or directory #55

Closed
candrews opened this issue Jan 24, 2017 · 12 comments
Closed

Can't cd to (unreachable)/: No such file or directory #55

candrews opened this issue Jan 24, 2017 · 12 comments
Assignees
Labels
Milestone

Comments

@candrews
Copy link
Contributor

This problem impacts version 2.11 (I did not have on any previous version).

Simply running needrestart yields this error:

Can't cd to (unreachable)/: No such file or directory===========================================================================                                                                                 ]

I suspect this problem was caused by 4e020cb

@candrews
Copy link
Contributor Author

Confirmed that if I revert the change made in 4e020cb to Perl.pm that needrestart works again.

@liske liske self-assigned this Jan 28, 2017
@liske liske added the bug label Jan 28, 2017
@liske liske added this to the v2.12 milestone Jan 28, 2017
@liske
Copy link
Owner

liske commented Jan 28, 2017

I'm unable to reproduce this issue. Could you please provide the output of ls -la /proc/$PID for the affected process?

@candrews
Copy link
Contributor Author

The error occurs at


I'm running sudo needrestart
$src is set to /usr/sbin/sqlgrey
$cwd is set to /home/candrews (if I run from other directories, I get the same error, so I don't think $cwd is important)
$pid is set to 15601

# ls -la /proc/15601
total 0
dr-xr-xr-x   9 sqlgrey sqlgrey 0 Jan 26 16:20 .
dr-xr-xr-x 314 root    root    0 Jan 22 17:34 ..
dr-xr-xr-x   2 sqlgrey sqlgrey 0 Jan 28 17:54 attr
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 autogroup
-r--------   1 sqlgrey sqlgrey 0 Jan 28 17:54 auxv
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 05:20 cgroup
--w-------   1 sqlgrey sqlgrey 0 Jan 28 17:54 clear_refs
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 27 16:43 cmdline
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 05:20 comm
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 coredump_filter
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 cpuset
lrwxrwxrwx   1 sqlgrey sqlgrey 0 Jan 28 17:38 cwd -> /
-r--------   1 sqlgrey sqlgrey 0 Jan 27 16:43 environ
lrwxrwxrwx   1 sqlgrey sqlgrey 0 Jan 27 16:43 exe -> /usr/bin/perl
dr-x------   2 sqlgrey sqlgrey 0 Jan 26 16:20 fd
dr-x------   2 sqlgrey sqlgrey 0 Jan 28 17:54 fdinfo
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 gid_map
-r--------   1 sqlgrey sqlgrey 0 Jan 28 04:21 io
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 limits
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 loginuid
dr-x------   2 sqlgrey sqlgrey 0 Jan 27 16:43 map_files
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 27 16:43 maps
-rw-------   1 sqlgrey sqlgrey 0 Jan 28 17:54 mem
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 mountinfo
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 mounts
-r--------   1 sqlgrey sqlgrey 0 Jan 28 17:54 mountstats
dr-xr-xr-x   5 sqlgrey sqlgrey 0 Jan 28 17:54 net
dr-x--x--x   2 sqlgrey sqlgrey 0 Jan 28 17:54 ns
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 oom_adj
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 oom_score
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 oom_score_adj
-r--------   1 sqlgrey sqlgrey 0 Jan 28 17:54 pagemap
-r--------   1 sqlgrey sqlgrey 0 Jan 28 17:54 personality
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 projid_map
lrwxrwxrwx   1 sqlgrey sqlgrey 0 Jan 27 16:43 root -> /
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 sched
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 schedstat
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 sessionid
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 setgroups
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 smaps
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 26 16:20 stat
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 04:21 statm
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 27 16:43 status
-r--------   1 sqlgrey sqlgrey 0 Jan 28 17:54 syscall
dr-xr-xr-x   3 sqlgrey sqlgrey 0 Jan 28 17:54 task
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 timers
-rw-rw-rw-   1 sqlgrey sqlgrey 0 Jan 28 17:54 timerslack_ns
-rw-r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 uid_map
-r--r--r--   1 sqlgrey sqlgrey 0 Jan 28 17:54 wchan

I'm using "dev-perl/Module-ScanDeps" version 1.230.0
perl is v5.24.1

sqlgrey is run as a systemd service. Here's that information:

# systemctl cat sqlgrey
# /usr/lib/systemd/system/sqlgrey.service
[Unit]
Description=SQLgrey Postfix Grey-listing Policy service
After=network.target

[Service]
User=sqlgrey
Group=sqlgrey
ExecStart=/usr/sbin/sqlgrey
CapabilityBoundingSet=
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=full
ProtectHome=yes
NoNewPrivileges=yes
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true

[Install]
WantedBy=multi-user.target

I'm using systemd 232.

@liske liske modified the milestones: v2.11-3, v2.12 Feb 10, 2017
@liske
Copy link
Owner

liske commented May 19, 2017

Maybe the issue is triggered by the ProtectSystem setting. Could you please try to run ls -la /proc/$PID/root (does it report an error?)?. Would it be possible for you to disable it temporary and check if the problem persists?

@candrews
Copy link
Contributor Author

I removed ProtectSystem=full from sqlgrey.service and restarted it. needrestart still failed with the same error.

I ran ls -la /proc/$PID/root (with $PID being the pid I discovered using the approach in #55 (comment) ) and it shows a directory listing, no errors.

@stbuehler
Copy link
Contributor

For starters I think there is a chdir($cwd) missing in NeedRestart/Interp/Perl.pm:143 to undo the current directory change before the return.

I have the same issue with sympa; with perl -MCarp::Always /usr/sbin/needrestart -v (after installing libcarp-always-perl) I get:

[Core] #10145 is a NeedRestart::Interp::Perl
/usr/share/perl5/NeedRestart/Interp/Perl.pm:107: chdir /proc/10145/root//var/lib/sympa/list_data
[Perl] #10145: source=/usr/lib/sympa/bin/archived.pl
Can't cd to (unreachable)/var/lib/sympa/list_data: No such file or directory
 at /usr/share/perl/5.24/File/Find.pm line 283.
        File::Find::_find_opt(HASH(0x562a04ecc118), "/usr/lib/x86_64-linux-gnu/perl/5.24/auto/POSIX") called at /usr/share/perl/5.24/File/Find.pm line 760
        File::Find::find(CODE(0x562a04ecbe90), "/usr/lib/x86_64-linux-gnu/perl/5.24/auto/POSIX") called at /usr/share/perl5/Module/ScanDeps.pm line 1177
        Module::ScanDeps::_glob_in_inc("auto/POSIX") called at /usr/share/perl5/Module/ScanDeps.pm line 1104
        Module::ScanDeps::add_deps("used_by", "archived.pl", "rv", HASH(0x562a04ecb5c0), "modules", ARRAY(0x562a04ecbd10), "skip", undef, ...) called at /usr/share/perl5/Module/ScanDeps.pm line 684
        Module::ScanDeps::scan_deps_static(HASH(0x562a050e4798)) called at /usr/share/perl5/Module/ScanDeps.pm line 614
        Module::ScanDeps::scan_deps("files", ARRAY(0x562a04ecb728), "recurse", 1) called at /usr/share/perl5/NeedRestart/Interp/Perl.pm line 165
        NeedRestart::Interp::Perl::files(NeedRestart::Interp::Perl=HASH(0x562a04eee548), 10145, HASH(0x562a04aa3410)) called at /usr/share/perl5/NeedRestart.pm line 171
        NeedRestart::needrestart_interp_check(1, 10145, "/usr/bin/perl", ARRAY(0x562a04e46280)) called at /usr/sbin/needrestart line 498

This is debian stretch amd64, with another print for the chdir debug line, and the fixed chdir before return.

@candrews
Copy link
Contributor Author

candrews commented Jul 5, 2017

@stbuehler can you please submit a pull request with your suggested change?

@stbuehler
Copy link
Contributor

I guess you misunderstood me; the missing cwd restore was a bug, but not this bug - the output I showed with the backtrace of the problem was done with #70 already applied.

@renini
Copy link

renini commented Oct 26, 2017

Did this fix work for everyone? We currently experience this on lxc host running debian stable (stretch).
Tried needrestart 2.11-3 and 2.11-4

@nirgal
Copy link
Contributor

nirgal commented Nov 11, 2018

I got the same issue after yesterday's Debian update (Version 9.6).

I have

command[needrestart]=sudo /usr/sbin/needrestart -p 2>&1

and a /etc/sudoers.d/needrestart file containing:

# Grant nrpe right to run needrestart as root
nagios     ALL=(root) NOPASSWD: /usr/sbin/needrestart -p

The error was:

/usr/lib/nagios/plugins/check_nrpe -H xxxxx.nirgal.com -c needrestart
Can't cd to (unreachable)/: No such file or directory

I did tried this fix (8311453) but it did not work.

Finally, I fixed it by switching back to system-v: aptitude install sysvinit-core.

@vdboor
Copy link

vdboor commented Nov 19, 2018

I can confirm this, needrestart is broken by the Debian 9.6 update. The same error occurs:

$ needrestart  -v
[main] eval /etc/needrestart/needrestart.conf
[main] needrestart v3.3
[main] running in root mode
[Core] Using UI 'NeedRestart::UI::stdio'...
[main] systemd detected
[main] #11763 uses deleted /lib/x86_64-linux-gnu/libsystemd.so.0.23.0
[main] #11763 is not a child
[Core] #18453 is a NeedRestart::Interp::Perl
[Perl] #18453: source=/usr/sbin/munin-node
Can't cd to (unreachable)/: No such file or directory

Stopping munin-node allowed needrestart to continue

@liske
Copy link
Owner

liske commented Jan 30, 2019

This issue seems to be related to #125.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants