LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-30-2019, 10:16 PM   #16
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,470

Rep: Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813

Quote:
Originally Posted by crts View Post
The original script is only supposed to handle damaged permissions whose s/t-bits are still correct. However, someone may also have inadvertently damaged those, too. This why I decided to use the symbolic modes.
TBH, I don't remember the numerical values without effort (after all, who configures ls to output the numeric values?); I would find the symbolic modes better to understand what's going on.
 
Old 10-07-2019, 08:38 AM   #17
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,461

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
needs cleanup, and some options adding

it won't be perfect, but should fix most things and at least get the system bootable again
Code:
#!/bin/bash
Flags=( "${@}" ) # grab hold of flags early

# Errata

# PrintCosmetic Outputs to stderr, just keeping you up-to-date with what the
# script is processing. However, it slows things down so I commented it out

# LVM, added a function to fix perms related to lvm
# it should be called after Hammer()

################################################################################
# Default configuration 
################################################################################
    manifest_missing="return 10"
    manifest_invalid="return 20"
     CompTypeUnknown="return 30"
          CompGrepNA="return 40"
        UnknownError="return 99"
            Manifest="$1"
            MNTPOINT="$2"
               XARGS="xargs -r echo"
            # remove echo if you want to action immediatly
################################################################################
Help () {
#TODO write this
    echo "Use the Force, read the src."
    exit 0
}
ChkManifest () {
    [[ -z "${Manifest}" ]] && $manifest_missing
    [[ -e "${Manifest}" ]] || $manifest_missing
    fileis=( $( file -i "${Manifest}" ) )
    case ${fileis[1]:0:(-1)} in
        text/plain)
            GREP="$( which grep )" || $CompGrepNA
            ;;
        application/gzip)
            GREP="$( which zgrep )" || $CompGrepNA
            ;;
        application/x-bzip2)
            GREP="$( which bzgrep )" || $CompGrepNA
            ;;
        application/x-xz)
            GREP="$( which xzgrep )" || $CompGrepNA
            ;;
        application/x-lzma)
            GREP="$( which lzgrep )" || $CompGrepNA
            ;;
        application/x-zstd)
            GREP="$( which zstdgrep )" || $CompGrepNA
            ;;
        *)
            $CompTypeUnknown
            ;;
    esac
    chk=( $($GREP -m1 -E -- "^[bcd-][rwxsStT-]{9}.*[a-z]/?$" ${Manifest}) )
    [[ ${#chk[@]} == 6 ]] \
        && [[ ${chk[0]} =~ ^[bcdrwxsStT-]{10}$ ]] \
        && [[ ${chk[1]} =~ ^[a-z]*/[a-z]*$ ]] \
        && [[ ${chk[2]} =~ ^[0-9]+,?[0-9]*$ ]] \
        && [[ ${chk[3]} =~ ^[1-2][0,9][0-3,7-9][0-9]-[0-1][0-9]-[0-3][0-9]$ ]] \
        && [[ ${chk[4]} =~ ^[0-5][0-9]:[0-5][0-9]$ ]] \
        && [[ ${chk[5]} =~ ^[[:print:]]+$ ]] \
        || $manifest_invalid
    # overkill, but we only do it once
return 0
}
################################################################################
# GetIndex #
# unlikely with slackware's   tar vtf package.txz >> MANIFEST
# but if the manifest were in a different order to what we expect
# this could be used to find the array indices we need
# only PERMS, OWNER_GRP and FILEPATH are used in this script
# they are META[0] , META[1] and META[5]
# so you would change those to META[$PERMS], META[$OWN_GRP] META[$FILE_PATH]
# you would also need to correct the sort field in ReadManifest()
GetIndex () {
################################################################################
for i in ${!chk[@]}
do
    [[ ${chk[i]} =~ ^[bcdrwxsStT-]{10}$ ]] \
        && PERMS=$i || continue
    [[ ${chk[i]} =~ ^[a-z]+/[a-z]+$ ]] \
        && OWN_GRP=$i || continue
    #[[ ${chk[i]} =~ ^[0-9]+,?[0-9]*$ ]] \
    #   && SIZE=$i || continue
    #[[ ${chk[i]} =~ ^[1-2][0,9][0-3,7-9][0-9]-[0-1][0-9]-[0-3][0-9]$ ]] \
    #   && FILEDATE=$i || continue
    #[[ ${chk[i]} =~ ^[0-5][0-9]:[0-5][0-9]$ ]] \
    #   && FILETIME=$i || continue
    [[ ${chk[i]} =~ ^[[:print:]]+$ ]] \
        && FILE_PATH=$i || continue
done
# not without issues. The RE for FILE_PATH is way too open and the RE for own_grp
# could also match a filepath. It would be better to seed the chk array with "etc"
# and look for:- "^[bcdrwxsStT-]{10}$" "^root.root$" "^.*etc/?$"
}

################################################################################
ReadManifest () {
################################################################################
    sort -u -d -k6 <($GREP -E -- "$1" "${Manifest}" )
return 0
}
################################################################################
Textual_to_Octal () {
################################################################################
    S=0 # unset special bits by default
    # bash arrays start at 0, so 3 is 4th in string
    [[ ${1:3:1}  =~ [sS] ]] && S=$(( ${S} + 4 )) ##\
    [[ ${1:6:1}  =~ [sS] ]] && S=$(( ${S} + 2 ))   # set as per manifest
    [[ ${1:(-1)} =~ [tT] ]] && S=$(( ${S} + 1 )) ##/

    # only need to declare once
    [[ $p ]] || declare -A \
        p=(
            [r]="4" [w]="2" [x]="1" [-]="0"
            [s]="1" [S]="0" [t]="1" [T]="0"
          )
    # S ( s{u,g}id no exec. ) is unlikly to exist in manifest, but it is valid

    printf "0%d%d%d%d" \
        ${S} \
        $(( ${p[${1:1:1}]} + ${p[${1:2:1}]} + ${p[${1:3:1}]} )) \
        $(( ${p[${1:4:1}]} + ${p[${1:5:1}]} + ${p[${1:6:1}]} )) \
        $(( ${p[${1:7:1}]} + ${p[${1:8:1}]} + ${p[${1:9:1}]} ))

################################################################################
# ${1} is what we fed into the function ( drwxr-xr-x )
# p is our Associative array, bit values are indexed with textual char.
# :1:1} == r ( the second element of the string d(r)wxr-xr-x )
# special   User          Group         Other        
# no s / S  ${p[r]} == 4  ${p[r]} == 4  ${p[r]} == 4
# no t / T  ${p[w]} == 2  ${p[-]} == 0  ${p[-]} == 0
#           ${p[x]} == 1  ${p[x]} == 1  ${p[x]} == 1
# sum == 0     sum  == 7     sum  == 5     sum  == 5  >>  0755 
}
################################################################################
Textual_to_Symbolic () {
################################################################################

        SUID=",u-s"  ##\
        SGID=",g-s"    # unset special bits by default
      STICKY=",o-t"  ##/

    [[ ${1:3:1}  =~ [sS] ]] &&   SUID="s"  ##\ 
    [[ ${1:6:1}  =~ [sS] ]] &&   SGID="s"    # set as per manifest
    [[ ${1:(-1)} =~ [tT] ]] && STICKY="t"  ##/

    perms="${1//[st]/x}"      # s and t imply exec. bit
    perms="${perms//[ST-]/ }" # S and T imply no exec. bit
    perms="\
            u=${perms:1:3}${SUID},\
            g=${perms:4:3}${SGID},\
            o=${perms:7:3}${STICKY}\
          "
    perms="${perms//[[:space:]]}" # remove white space.

    printf "%s" "${perms}"

}
################################################################################
Hammer () {
################################################################################
# chmod pretty much everything
# Why?
# it will fix anything "extra" that is not in the manifest
# no real sense in leaving rogue 777 dirs/files hanging around

    # dirs 00755
    $XARGS chmod -v 00755 < <( find ${MNTPOINT}/ -xdev \
          -type d \
        ! -regex "${MNTPOINT%/}\(/lost.found\|/home\)/" \
        ! -perm 0755
    )

    # files in a /{s}bin/ 00755
    $XARGS chmod -v 00755 < <( find ${MNTPOINT}/ -xdev \
          -type f \
          -regex "\(.*/s?bin/.*\)\|\(.*/pkgtools/\(.*scripts|setup\)/.*\)" \
        ! -regex "${MNTPOINT%/}\(/home/.*\)\|\(/tmp/.*\)" \
        ! -perm 0755
    )

    # files not in a /{s}bin/ 00644
    $XARGS chmod -v 00644 < <( find ${MNTPOINT}/ -xdev \
          -type f \
        ! -regex "\(.*/s?bin/.*\)\|\(.*/pkgtools/\(.*scripts|setup\)/.*\)" \
        ! -regex "${MNTPOINT%/}\(/home/.*\)\|\(/tmp/.*\)" \
        ! -perm 0644
    )

# Yes, many more locations should have exec. scripts
# These will be fixed when manifest is processed
}
################################################################################
LVM () {
################################################################################
#TODO add option for this ( or look to see if needed )
    # lvm dirs
    $XARGS chmod -v 00700 < <( find ${MNTPOINT}/etc/lvm -xdev \
          -type d \
          -regex ".*/lvm/\(archive\|backup\|cache\)" \
        ! -perm 0700
    )
    # lvm files
    $XARGS chmod -v 00600 < <( find ${MNTPOINT}/etc/lvm -xdev \
          -type f \
          -regex ".*/lvm/\(archive\|backup\|cache\)/.*" \
        ! -perm 0600
    )
    $XARGS chmod -v 00444 < <( find ${MNTPOINT}/etc/lvm -xdev \
          -type f \
          -regex ".*/lvm/profile/.*" \
        ! -perm 0444
    )
}
################################################################################
QueryManifest () {
################################################################################
# [0]="Perms" [1]="Owner/Group [2]="Size|Major/Minor"
# [3]="Date"  [4]="Time"       [5]="Path/file"
while read -a META
do
    # skip 1994 var/run with incorrect perms
    [[ ${META[5]} == var/run/ && ${META[0]} == drwxrwxr-x ]] \
        && continue

    #PrintCosmetic $FUNCNAME "${META[5]}"

    # check file/dir exists
    # this is redundedent if we assume a "complete" install
    # TODO add option to assume all files/dirs exist
    # But time saved may not be worth it.
    [[ -e "${MNTPOINT}/${META[5]}" ]] \
        && printf "%s\n" "${MNTPOINT}/${META[5]}"

    # files ending .new may or may not exist
    # But these are temp. files, so also check after stripping .new
    [[ ${META[5]:(-4)} == \.new ]] \
        || continue \
        && ni=${#META[@]} \
        && META[$ni]=${META[5]%.new}

    #PrintCosmetic $FUNCNAME "${META[$ni]}"

    [[ -e "${MNTPOINT}/${META[$ni]}" ]] \
        && printf "%s\n" "${MNTPOINT}/${META[$ni]}"

done< <( ReadManifest "${1}" )
}
################################################################################
ErrorReport () {
################################################################################
ExitCode=$?
# since I'm posting this where tabs cannot be input I have removed leading tabs.
# the - in <<- strips the leading tabs from output
# if you want readability re-add the tabs, 
# NOTE I lead with two spaces, IMO output looks better with a margin.
#
# The nice thing about this function is Creepers will not dare come near!
case ${ExitCode} in
    10) cat <<-EOF
  MANIFEST required
  $0 /path/to/MANIFEST.bz2
EOF
        ;;
    20) cat <<-EOF
  "${Manifest}" does not appear to be a validi Manifest
  edit the script to skip this test
  I will add a flag later
EOF
        ;;
    30) Foo=($(grep -o -E "(text|application)/[a-z-]*" "$0" ))
        Foo=(${Foo[@]#app*/})
        cat <<-EOF
  "${fileis[1]:0:(-1)}" not supported
  valid compressions are ${Foo[@]/x-}
EOF
        ;;
    40) compresion="${fileis[1]:0:(-1)}"
        compresion="${compresion#app*/}"
        cat <<-EOF
  grep supporting ${compresion/x-} not found
EOF
        ;;
    99) cat <<-EOF
  Unknown Error
  I hope "$Error"
  makes some sense to you
EOF
        ;;
esac
exit ${ExitCode}
}
################################################################################
PrintCosmetic () {
################################################################################
# calls to this are commented out as it slows things down quite a bit.
# Although, the slowdown is just mins, not 10s of mins.
    case $1 in
        Filter|OwnGrpFilter)
            printf "%-${COLUMNS}s\n" "Current filter ${2}" 1>&2
            ;;
        QueryManifest)
            #TODO put prefix into a var
    [[ $(( ${#2} + 9 )) -gt ${COLUMNS} ]] \
        || printf "%-${COLUMNS}s\r" \
            "Checking ${2}" 1>&2 \
        && printf "%-${COLUMNS}s\r" \
            "Checking ${2:$(( $(( ${#2} + 9 )) - $COLUMNS ))}" 1>&2
            ;;
    esac
}
################################################################################
Filter () {
################################################################################
# Initially I had QueryManifest printing the chmod/chown for each line
# This Filter now groups each "unique" chmod and executes as a block via xargs
# Which should be much quicker ( but generated script will look ugly as hell )

    filter="${1:-[drwxstT-]{10}}" #TODO include block/char when root is MNTPOINT
    while read -a FILTER
    do
        #PrintCosmetic $FUNCNAME "${FILTER[0]}"

        $XARGS chmod -v $( Textual_to_Octal ${FILTER[0]} ) \
            < <(QueryManifest "^${FILTER[0]}")
    done < <(sort -u < <($GREP -Eo -- "${filter}" "${Manifest}") )
}
################################################################################
OwnGrpFilter () {
################################################################################
# I ignored chown for a while, this re-adds that, same logic as Filter
# with regards to doing as a block

# Note, seperate chown does greatly increase the processing time
# However, in the case of fixing a "chmod -R 777 /" chown would not be
# needed, so I figured it would be better to have as a non default option.

    filter="${1:- [a-z]+/[a-z]+ }"
    while read -a FILTER
    do
        #PrintCosmetic $FUNCNAME "\" ${FILTER[0]/\//:} \""

        $XARGS chown ${FILTER[0]/\//:} \
            < <(QueryManifest "^[d-].* ${FILTER[0]} ")
    done < <(sort -u < <($GREP -Eo -- "${filter}" "${Manifest}") )
    # FIXME ^[d-] hardcodes to ignore block/char
}
################################################################################
trap ErrorReport EXIT
################################################################################
[[ $# == 0 ]] && Help
    ChkManifest || exit $?
    # Hammer will need root, add a euid check
    Hammer
    Filter
#   OwnGrpFilter
#echo $SECONDS

Edit: fixed the var/run correction
Code:
    # fix 1994 var/run with incorrect perms
    [[ ${META[5]} == var/run/ && ${META[0]} == drwxrwxr-x ]] \
        && continue
        #&& META[0]="drwxr-xr-x"
since the function now processes blocks based on the perms and not line by line it must be skipped instead of being fixed

Last edited by Firerat; 10-07-2019 at 12:02 PM.
 
Old 10-07-2019, 08:41 AM   #18
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,461

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by crts View Post
How productive ... Slackware would be truely lost without your "deep, thoughtful" insights.



You could try the following script:

Code:
#!/usr/bin/bash

MANIFEST="${1:-./MANIFEST}"
ROOT="$2"

transform_perms() {
        local f="${1,,}" # field to be transformed into valid chmod permission (u,g,o)
        local p="${2}" # the permission as read from the manifest file
        local s=${3:-s}
        local r

        case ${p:2} in
        x|-) # must remove s-bit explicitly
                r="$f=${p//-/},${f}-${s,,}"
                ;;
        s|t) # lower case s-bit implies exec bit 
                r="$f=${p//-/}x"
                ;;
        *)
                r="$f=${p//-/}"
                ;;
        esac

        echo "${r,,}"
}

reset_perms() {
        local read perm user_group size date time file u g o filepath

        while read perm user_group size date time file;do
                [[ ${perm:0:1} == [^hdbcps-] ]] && continue;

                u=$(transform_perms u "${perm:1:3}")
                g=$(transform_perms g "${perm:4:3}")
                o=$(transform_perms o "${perm:7:3}" t)

                [[ ${perm:0:1} == h ]] && file="${file% link to *}"

                filepath="$ROOT/$file"
                chown ${user_group/\//:} "$filepath"
                chmod $u,$g,$o "$filepath"
        done < "$MANIFEST"
}

reset_perms
Just do me a favor and run

Code:
# chmod -R 7777 / # yes, that is four 7s
to "screw" up the system in your VM. I would like to know if it handles the SUID/SGID bits for directories correctly because the way chmod handles them is not trivial.

nice idea, I would never have thought to go with longhand chmod

this is much faster than your script ( around twenty times faster )

Code:
#!/bin/bash
go () {
while read -a META
do
# META
# [0]="Perms" [1]="Owner/Group [2]="Size|Major/Minor"
# [3]="Date"  [4]="Time"       [5]="Path/file
    n="${#META[@]}" # I will use this to index new array element

        SUID=",u-s"  ##\
        SGID=",g-s"   # unset special bits by default
      STICKY=",o-t"  ##/

    [[ ${META[0]:3:1}  =~ [sS] ]] &&   SUID="s"  ##\ 
    [[ ${META[0]:6:1}  =~ [sS] ]] &&   SGID="s"    # set as per manifest
    [[ ${META[0]:(-1)} =~ [tT] ]] && STICKY="t"  ##/

    META[$n]="${META[0]//[st]/x}"   # s and t imply exec. bit
    META[$n]="${META[$n]//[ST-]/ }" # S and T imply no exec. bit
    META[$n]="\
                u=${META[$n]:1:3}${SUID},\
                g=${META[$n]:4:3}${SGID},\
                o=${META[$n]:7:3}${STICKY}\
             "
    META[$n]="${META[$n]//[[:space:]]}" # remove white space.

    printf "\t%s\n" "chown ${META[1]/\//:} /${META[5]}"
#   printf "\t%s\n" "#chmod ${META[0]} /${META[5]}"
    printf "\t%s\n" "chmod ${META[$n]} /${META[5]}"
done< <( grep ^[d-] $1 )
}
time go "${1:-./MANIFEST}"
 
Old 10-07-2019, 08:45 AM   #19
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,461

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by crts View Post
It does so because you cannot remove an erroneous SUID/SGID bit with the numeric ones. From the manpage:

Code:
SETUID AND SETGID BITS
       chmod  clears  the  set-group-ID  bit  of a regular file if the file's
       group ID does not match the user's effective group ID or  one  of  the
       user's supplementary group IDs, unless the user has appropriate privi‐
       leges.  Additional restrictions may cause  the  set-user-ID  and  set-
       group-ID  bits  of MODE or RFILE to be ignored.  This behavior depends
       on the policy and functionality of the underlying chmod  system  call.
       When in doubt, check the underlying system behavior.

       chmod preserves a directory's set-user-ID and set-group-ID bits unless
       you explicitly specify otherwise.  You can set or clear the bits  with
       symbolic  modes  like u+s and g-s, and you can set (but not clear) the
       bits with a numeric mode.
The original script is only supposed to handle damaged permissions whose s/t-bits are still correct. However, someone may also have inadvertently damaged those, too. This why I decided to use the symbolic modes.
It appears you got confused by the manual ( and you didn't include the relevant part )

The below should enlighten you
Code:
touch foo ; chmod 7777 foo
stat -c %A_%a foo ; chmod 5 foo ; stat -c %A_%a foo
# -rwsrwsrwt_7777  
# -------r-x_0005
it would appear chmod assumed leading 000

Code:
mkdir FOO ; chmod 7777 FOO ; stat -c %A_%a FOO ; chmod 5 FOO ; stat -c %A_%a FOO
# drwsrwsrwt_7777
# d--S--Sr-x_6005
well, it tried
lets try harder and use a 0 padded 5 digit Octal
Code:
chmod 7777 FOO ; stat -c %A_%a FOO ; chmod 00005 FOO ; stat -c %A_%a FOO
# drwsrwsrwt_7777
# d------r-x_0005
effective ID may also have confused you
pick a group you are not a member of
Code:
touch foobar;sudo chgrp man foobar;stat -c %A_%a_%U_%G foobar
# -rw-r--r--_644_firerat_man
chmod 7777 foobar ;stat -c %A_%a_%U_%G foobar
# -rwsrwxrwt_5777_firerat_man
the sgid bit was silently dropped
even -v will miss report the chmod
Code:
sudo chmod 655 foobar
chmod -v 7777 foobar ;stat -c %A_%a_%U_%G foobar 
# mode of 'foobar' changed from 0655 (rw-r-xr-x) to 7777 (rwsrwsrwt)
# -rwsrwxrwt_5777_firerat_man
you need to be a member of the group, or be god ( root )
Code:
sudo chmod 655 foobar
sudo chmod -v 7777 foobar ;stat -c %A_%a_%U_%G foobar 
# mode of 'foobar' changed from 0655 (rw-r-xr-x) to 7777 (rwsrwsrwt)
# -rwsrwsrwt_7777_firerat_man
If you are removing s{u,g}id from a dir you *must* use 5 digits leading with a 0
it does no harm to use a 0 padded 5 digit Octal on a file

Code:
mkdir FOOBAR;chmod -v 7777 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR 
# mode of 'FOOBAR' changed from 0755 (rwxr-xr-x) to 7777 (rwsrwsrwt)
# drwsrwsrwt_7777_firerat_firerat
chmod -v 755 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR
# mode of 'FOOBAR' changed from 7777 (rwsrwsrwt) to 6755 (rwsr-sr-x)
# drwsr-sr-x_6755_firerat_firerat
sudo chmod -v 755 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR
# mode of 'FOOBAR' changed from 7777 (rwsrwsrwt) to 6755 (rwsr-sr-x)
# drwsr-sr-x_6755_firerat_firerat
chmod -v 0755 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR
# mode of 'FOOBAR' retained as 6755 (rwsr-sr-x)
# drwsr-sr-x_6755_firerat_firerat
sudo chmod -v 0755 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR
# mode of 'FOOBAR' retained as 6755 (rwsr-sr-x)
# drwsr-sr-x_6755_firerat_firerat
chmod -v 00755 FOOBAR ;stat -c %A_%a_%U_%G FOOBAR
# mode of 'FOOBAR' changed from 6755 (rwsr-sr-x) to 0755 (rwxr-xr-x)
# drwxr-xr-x_755_firerat_firerat
Manuals are for reference, you should always test what you learn from them.
The manual may be incorrect ( out of date ), or you may have simply miss-understood it.
 
Old 10-07-2019, 08:45 AM   #20
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,282

Rep: Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924Reputation: 1924
Quote:
needs cleanup, and some options adding
Are you talking about the code?
Welcome back.
 
Old 10-07-2019, 09:02 AM   #21
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,461

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by allend View Post
Are you talking about the code?
Welcome back.
yeah, it might need some tweaks to include block and char devices
I decided to ignore those since /dev/ is actually going to be a devtmpfs

I hacked Own_Grp back in as a separate function call, but I would like to merge that with Filter()

It also needs to be more active with error checking

dirs/files not included in the manifest will remain 0755/0644
I did add LVM() which starts to address things like that.

I did also start an Options function
Code:
#!/bin/bash
Flags=("$@")

Options (){
    for f in ${!Flags[@]}
    do
        case ${Flags[$f]} in
        *MANIFEST*)
            [[ -f ${Flags[$f]} ]] \
                && Manifest="${Flags[$f]}"
            ;;
        -m|--manifest)
            [[ -f ${Flags[$(( $f + 1 ))]} ]] \
                && Manifest="${Flags[$(($f + 1))]}"
            ;;
        -r|--root|-mp|-mount)
            [[ -e ${Flags[$(( $f + 1 ))]%/}/etc/os-release ]] \
                && MNTPOINT="${Flags[$(($f + 1))]}" \
                || invalidmountpoint="${Flags[$(($f + 1))]}"
            ;;
        -chown|-og)
            IncludeChown=yes
            ;;
        -nodev)
            IncludeDev=no
            ;;
        -s|--skip-exists-check)
            SKIPEXISTSCHK="yes"
            ;;
        esac
    done
}

Options

echo $Manifest
echo $MNTPOINT
echo $SKIPEXISTSCHK
echo imp $invalidmountpoint
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restoring file and directory permissions on Centos 6.5, 64 bit using Live CD jyunker Linux - Newbie 15 01-21-2014 07:57 AM
restoring default device ownerships/permissions under_r_run Linux - Newbie 5 07-27-2005 01:27 PM
Need help restoring /var permissions Thiink Slackware 1 02-21-2005 05:36 AM
Help restoring file permissions from a Dump bminish Linux - Newbie 3 12-12-2004 01:34 PM
restoring mysql databases? and mysql permissions... armegeden Linux - Software 0 03-13-2003 11:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration