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

CentOS 6 init script errors #3463

Closed
DeHackEd opened this issue May 31, 2015 · 10 comments
Closed

CentOS 6 init script errors #3463

DeHackEd opened this issue May 31, 2015 · 10 comments

Comments

@DeHackEd
Copy link
Contributor

# service zfs-import start
/usr/local/etc/zfs/zfs-functions: line 32: log_begin_msg: command not found
/usr/local/etc/zfs/zfs-functions: line 33: log_end_msg: command not found
# service zfs-mount start
/usr/local/etc/zfs/zfs-functions: line 32: log_begin_msg: command not found
/usr/local/etc/zfs/zfs-functions: line 33: log_end_msg: command not found
/usr/local/etc/zfs/zfs-functions: line 377: export: `MTAB__home_name-with-dashes=atmaweapon/home/name-with-dashes': not a valid identifier
[repeats for all applicable datasets]

So we have a bash function that doesn't exist (I couldn't find it anywhere in CentOS 6.6) and a failure when dataset names have hyphens in them.

For reference, log_*_msg functions are PARTIALLY defined in /lib/lsb/init-functions on CentOS 6, but a reading of zfs-functions suggests that for redhat systems we actually want to use a different set of functions from /etc/[rc.d/]init.d/functions

@behlendorf
Copy link
Contributor

@DeHackEd right so what should be happening is that we detect and use use the Fedora/Redhat wrappers. But it looks like you're CentOS 6.6 system has a /lib/lsb/init-functions file installed which is throwing things off. What package provides this on your system?

@DeHackEd
Copy link
Contributor Author

DeHackEd commented Jun 2, 2015

# rpm -qif /lib/lsb/init-functions 
Name        : redhat-lsb-core              Relocations: (not relocatable)
Version     : 4.0                               Vendor: CentOS
Release     : 7.el6.centos                  Build Date: Fri 22 Feb 2013 06:24:28 AM EST
Install Date: Sun 02 Jun 2013 08:38:38 AM EDT      Build Host: c6b9.bsys.dev.centos.org
Group       : System Environment/Base       Source RPM: redhat-lsb-4.0-7.el6.centos.src.rpm
Size        : 22825                            License: GPL
Signature   : RSA/SHA1, Sat 23 Feb 2013 12:38:49 PM EST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem 
URL         : http://www.linuxfoundation.org/collaborate/workgroups/lsb
Summary     : LSB base libraries support for CentOS
Description :
The Linux Standard Base (LSB) Core Libraries Specifications define components
that are required to be present on an LSB conforming system.

Sounds important, but yum is allowing me to uninstall it with no significant collateral damage.

@FransUrbo
Copy link
Contributor

Ok, so if CentOS have a (partial) /lib/lsb/init-functions file, the solution should be reasonable easy to fix. We check for the lsb file last… ?

FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
@FransUrbo
Copy link
Contributor

I've pushed a fix for this, @DeHackEd could you take a look and test this?

FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* If find/awk doesn't exist but 'busybox' do, create a wrapper function.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* If find doesn't exist but 'busybox' do, create a wrapper function.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 2, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
@DeHackEd
Copy link
Contributor Author

DeHackEd commented Jun 3, 2015

You need to take 9012354 to heart. I applied the patch, rebuilt and reinstalled, but the scripts were not rebuilt and I ended up rebooting for nothing. I don't usually run make distclean.

Accounting for this, I did come across one more error. Sorry.

/usr/local/etc/zfs/zfs-functions: line 378: export: `MTAB__home_dhe_.cache=atmaweapon/home/dhecache': not a valid identifier

I put this on its own filesystem because this is where Firefox churns its cache and I don't want/need that snapshotted.

FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 3, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes and dots in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.
* Rebuild scripts if any of the *.in files changed.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
@FransUrbo
Copy link
Contributor

@DeHackEd Ok, new version for you to check.

FransUrbo added a commit to FransUrbo/zfs that referenced this issue Jun 3, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes and dots in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.
* Rebuild scripts if any of the *.in files changed.
* Move the sed part that filters out duplicates inside the check fo
  valid variable.

Signed-off-by: Turbo Fredriksson [email protected]
Closes openzfs#3463
Closes openzfs#3457
@behlendorf
Copy link
Contributor

@DeHackEd I did merge 9012354 but it looked like we dropped that when these change were merged, and I see @FransUrbo has added it back in his patch.

Interesting, I wish I'd known redhat-lsb-core existed perhaps we could have just relied on that.

I haven't determine if it's related to this change but I'm encountering an odd permission denied error on boot under CentOS6.

Mounting ZFS filesystem(s)  Permission denied the ZFS utilities must be run as root.
cannot mount 'tank': Resource temporarily unavailable
Permission denied the ZFS utilities must be run as root.
cannot mount 'tank/dbench': Resource temporarily unavailable

kernelOfTruth pushed a commit to kernelOfTruth/zfs that referenced this issue Jun 8, 2015
* Change the order of the function library check/load.
  Redhat based system _can_ have a /lib/lsb/init-functions file (from
  the redhat-lsb-core package), but it's only partially what we can use.
  Instead, look for that file last, giving the script a chance to catch
  the 'real' distribution file.
* Filter out dashes and dots in dataset name in read_mtab().
* Get rid of 'awk' entirely. This is usually in /usr, which might not
  be availible.
* Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not
  be availible). Instead use echo in a for loop.
* Rebuild scripts if any of the *.in files changed.
* Move the sed part that filters out duplicates inside the check fo
  valid variable.

Signed-off-by: Turbo Fredriksson [email protected]
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#3463
Closes openzfs#3457
@driehuis
Copy link

TL;DR

As a workaround for the must be run as root error message, make sure SELinux is not in enforcing mode on CentOS.

I'm seeing this error as well. From /var/log/boot.log:

Mounting ZFS filesystem(s)  Permission denied the ZFS utilities must be run as root.

I'm not only getting it on boot, but also upon calling the init script:

$ sudo /etc/init.d/zfs-mount start
Mounting ZFS filesystem(s)  Permission denied the ZFS utilities must be run as root.
cannot mount 'repo': Resource temporarily unavailable
Permission denied the ZFS utilities must be run as root.
cannot mount 'repo/yum': Resource temporarily unavailable
                                                           [FAILED]

When I call the start script specifying "sh" as the shell, it works for reasons I can't quite fathom yet:

$ sudo sh /etc/init.d/zfs-mount start
Mounting ZFS filesystem(s)                                 [  OK  ]

(up to date CentOS release 6.7, zfs-0.6.5.3-1.el6.x86_64)

Obviously, having to manually mount the filesystem is a show stopper for me. Never had this on Ubuntu. The sh invocation that works uses the same /bin/sh as the shebang in /etc/init.d/zfs-mount. I'm at a loss to see how these invocations differ.

So I thought, hmmm, redhatish OS, weird behavior, works on Ubuntu, sounds like SELinux. And lo and behold, sudo sh -c 'echo 0 >/selinux/enforce' works its miracles. I'll make sure SELinux is disabled at boot, so I can debug this issue at my leasure.

If I ever find out how to solve this properly, I'll create a new issue with a pull request, but don't hold your breath for it to materialize.

@justinpryzby
Copy link

I'm experiencing the "permission denied" issue having just upgraded from ubuntu xenial to bionic (probably it was always an issue). I also upgraded from zfs-0.8.2 to 0.8.4. I guess it's due to security lable on the initscript:
$ ls -ldZ /etc/init.d/zfs-mount
-rwxr-xr-x. root root system_u:object_r:initrc_exec_t:s0 /etc/init.d/zfs-mount

I'm not sure what it should be. I guess it's a nonissue on centos7 and other distros using systemd.

@justinpryzby
Copy link

For anyone else using c6, I confirmed this is fixed like so:
sudo chcon system_u:object_r:unconfined_exec_t:s0 /etc/init.d/zfs-mount

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

Successfully merging a pull request may close this issue.

5 participants