anatol / booster

Fast and secure initramfs generator
MIT License
505 stars 45 forks source link

Read-only flag for root fs should overwrite the read-write flag #250

Open r0l1 opened 11 months ago

r0l1 commented 11 months ago

Current code

func mountFlags() (uintptr, string) {
    rootMountFlags, options := sunderMountFlags(rootFlags, rootAutodiscoveryMountFlags)
    if rootRo {
        rootMountFlags |= unix.MS_RDONLY
    }
    if rootRw {
        rootMountFlags &^= unix.MS_RDONLY
    }
    return rootMountFlags, options
}

Suggestion

func mountFlags() (uintptr, string) {
    rootMountFlags, options := sunderMountFlags(rootFlags, rootAutodiscoveryMountFlags)
    if rootRo {
        rootMountFlags |= unix.MS_RDONLY
    } else if rootRw {
        rootMountFlags &^= unix.MS_RDONLY
    }
    return rootMountFlags, options
}