1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #! /bin/sh -
- #
- # Turn shadow passwords on or off (based on Debian's shadowconfig.sh)
- #
- # Copyright (c) 2018 Matias Fonzo, <selk@dragora.org>.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- umask 022
- IFS='
- '
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
- usage()
- {
- echo "Usage: ${0##*/} [on|off]"
- echo "Turn shadow passwords ON or OFF."
- }
- # Exit immediately on any error
- set -e
- # Be immune to the following signals
- trap "" HUP INT QUIT ABRT TERM
- # Parse options
- case $1 in
- on | ON )
- pwck -q -r
- grpck -r
- pwconv
- grpconv
- chown root:root /etc/passwd /etc/group
- chmod 644 /etc/passwd /etc/group
- chown root:shadow /etc/shadow /etc/gshadow
- chmod 640 /etc/shadow /etc/gshadow
- echo "Shadow passwords are now on."
- ;;
- off | OFF )
- pwck -q -r
- grpck -r
- pwunconv
- grpunconv
- # sometimes the passwd perms get munged
- chown root:root /etc/passwd /etc/group
- chmod 644 /etc/passwd /etc/group
- echo "Shadow passwords are now off."
- ;;
- --help | -h )
- usage
- exit 0
- ;;
- -*)
- echo "Unrecognized option: $1" 1>&2
- usage
- exit 1
- ;;
- *)
- usage
- ;;
- esac
|