Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 552418 - openrc /etc/init.d/bootmisc: clean_run() checks permisions on / instead of /run
Summary: openrc /etc/init.d/bootmisc: clean_run() checks permisions on / instead of /run
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-17 21:35 UTC by Joe M
Modified: 2015-10-05 17:08 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe M 2015-06-17 21:35:33 UTC
init.sh mounts tmpfs on /run already.

/etc/init.d/bootmisc checks / read-write permissions and assumes that /run has the same permissions as /.

When the / is read-only, but not /run, this causes the clean_run() function to error out prematurely.

Reproducible: Always
Comment 1 William Hubbs gentoo-dev 2015-06-21 15:37:20 UTC
The purpose of the clean_run function is to make sure no files are in the /run mount point. This is the underlying directory for the /run tmpfs; not the tmpfs itself.

The clean_run function exits if / is not writable, because I can't think of a situation where / would not be writable and /run (the directory, not the tmpfs) would be writable.

What is the situation you think I am missing?
Comment 2 Joe M 2015-06-23 14:54:17 UTC
Hello William,

Thanks for taking a look at this.

(In reply to William Hubbs from comment #1)
> The purpose of the clean_run function is to make sure no files are in the
> /run mount point. This is the underlying directory for the /run tmpfs; not
> the tmpfs itself.
> 
> The clean_run function exits if / is not writable, because I can't think of
> a situation where / would not be writable and /run (the directory, not the
> tmpfs) would be writable.
> 
> What is the situation you think I am missing?

Below is the corresponding code in //lib64/rc/sh/init.sh. It is mounting /run already. When the clean_run function starts, the / and /run are different. Does that make sense or am I missing something?

Thanks

------------------------------------------------------------

# /run is a new directory for storing volatile runtime data.
# Read more about /run at https://lwn.net/Articles/436012
sys="$(openrc --sys)"

if [ ! -d /run ]; then
        if [ "$sys" = VSERVER ]; then
                if [ -e /run ]; then
                rm -rf /run
                fi
                mkdir /run
        else
                eerror "The /run directory does not exist. Unable to continue."
                return 1
        fi
fi

if [ "$sys" = VSERVER ]; then
        rm -rf /run/*
elif ! mountinfo -q /run; then
        ebegin "Mounting /run"
        rc=0
        if ! fstabinfo --mount /run; then
                mount -t tmpfs -o mode=0755,nodev,size=10% tmpfs /run
                rc=$?
        fi
        if [ $rc != 0 ]; then
                eerror "Unable to mount tmpfs on /run."
                eerror "Can't continue."
                exit 1
        fi
fi

checkpath -d $RC_SVCDIR
checkpath -d -m 0775 -o root:uucp /run/lock
Comment 3 William Hubbs gentoo-dev 2015-06-23 16:30:41 UTC
(In reply to Joe M from comment #2)
> Hello William,
> 
> Thanks for taking a look at this.
> 
> (In reply to William Hubbs from comment #1)
> > The purpose of the clean_run function is to make sure no files are in the
> > /run mount point. This is the underlying directory for the /run tmpfs; not
> > the tmpfs itself.
> > 
> > The clean_run function exits if / is not writable, because I can't think of
> > a situation where / would not be writable and /run (the directory, not the
> > tmpfs) would be writable.
> > 
> > What is the situation you think I am missing?
> 
> Below is the corresponding code in //lib64/rc/sh/init.sh. It is mounting
> /run already. When the clean_run function starts, the / and /run are
> different. Does that make sense or am I missing something?

The code in clean_run is not trying to clean out the tmpfs that is mounted by init.sh. It is trying to clean out the underlying /run directory which will have different content, and most of the time should have none.

William
Comment 4 Joe M 2015-06-30 19:27:53 UTC
> The code in clean_run is not trying to clean out the tmpfs that is mounted
> by init.sh. It is trying to clean out the underlying /run directory which
> will have different content, and most of the time should have none.
 
Makes sense, Thanks. This errors out when I have a readonly root. The error is harmless, hence, want to check if it needs to be an error.
Comment 5 Dustin C. Hatch 2015-07-11 18:12:47 UTC
I agree that this should not be an error. When / is read-only, this message is guaranteed to be shown (even if there is nothing to clean), but there is no real problem. If there is anything in the hidden /run directory, it will make no difference.

If you really want to display the message, it should at least be changed to ewarn.
Comment 6 William Hubbs gentoo-dev 2015-10-05 17:08:38 UTC
Several messages in the clean_run function have beeen converted to
warnings since this function does not affect operation of the system.

This has been done in commit bf0c0dd.

Thanks,

William