Skip to content

Unachored removal of Containeruser from /etc/group and /etc/gshadow #585

Description

@antalk2

sed -i \"s/\$Containeruser//g ; s/:,/:/g ; s/,\$//g\" /etc/group # remove existing entries for user in /etc/group

echo "# /etc/group /etc/gshadow
sed -i \"s/\$Containeruser//g ; s/:,/:/g ; s/,\$//g\" /etc/group   # remove existing entries for user in /etc/group
sed -i \"s/\$Containeruser//g ; s/:,/:/g ; s/,\$//g\" /etc/gshadow # remove existing entries for user in /etc/gshadow
"

prints

# /etc/group /etc/gshadow
sed -i "s/$Containeruser//g ; s/:,/:/g ; s/,$//g" /etc/group   # remove existing entries for user in /etc/group
sed -i "s/$Containeruser//g ; s/:,/:/g ; s/,$//g" /etc/gshadow # remove existing entries for user in /etc/gshadow

The format of /etc/group is groupName:password:GID:user1,user2,user3

  • The first pattern removes "$Containeruser". The pattern is not anchored. It will remove it from groupName or any other users name.
  • When the username removed correctly, we can have a surrounding of the hole:
    :$ (sole user), :, (first user) ,, (middle user) and ,$ (last user)
    sole user needs no correction. first user and last user are handled. middle user is not.

The format of /etc/gshadow is groupName:password:admin1,admin2,admin3:user1,user2,user3

I assume we also want to remove the username from the admin positions
This yields some new possible surroundings: :: (sole admin), ,: (last admin)

We still need to anchor "$Containeruser"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions