#!@SH@ # # opkhelper # src/oh-fixperms.sh # Fix permissions and ownerships of data files. # # Copyright (C) 2012 Patrick "P. J." McDermott # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . . '@pkgdatadir@/load.sm' main() { dir='dest' oh_init while getopts 'd:' opt; do case "${opt}" in d) dir="${OPTARG}" ;; ?) oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac done # Ensure that everything is owned by UID 0 and GID 0. oh_info "$(oh_get_msg 'chown')" find "${dir}" \ -exec 'chown' '-h' '0:0' '{}' ';' # Ensure that shared libraries, static libraries, and libtool archives # have a rw-r--r-- mode. oh_info "$(oh_get_msg 'chmod_lib')" find "${dir}" -type f -a ! -perm 644 \ -a \( -name '*.so*' -o -name '*.a' -o -name '*.la' \) \ -exec 'chmod' '644' '{}' ';' # Ensure that header files have a rw-r--r-- mode. if [ -d "${dir}/usr/include" ]; then oh_info "$(oh_get_msg 'chmod_include')" find "${dir}/usr/include" -type f -a ! -perm 644 \ -exec 'chmod' '644' '{}' ';' fi # Ensure that manual pages have a rw-r--r-- mode. if [ -d "${dir}/usr/share/man" ]; then oh_info "$(oh_get_msg 'chmod_man')" find "${dir}/usr/share/man" -type f -a ! -perm 644 \ -exec 'chmod' '644' '{}' ';' fi # Ensure that binary programs and service scripts have a rwxr-xr-x mode. for bindir in /usr/sbin /usr/bin /sbin /bin /usr/games /etc/init.d; do if [ -d "${dir}/${bindir}" ]; then oh_info "$(oh_get_msg 'chmod_bin')" "${bindir}" find "${dir}/${bindir}" -type f -a ! -perm 755 \ -exec 'chmod' '755' '{}' ';' fi done } main "${@}"