* mount.cc (mount_info::from_fstab): Read user fstab files from

/etc/fstab.d/$USER to avoid user write access to /etc.
	* postinstall: Use variables for filenames.  Create /etc/fstab.d dir
	with 01777 permissions.
This commit is contained in:
Corinna Vinschen 2008-04-08 16:12:24 +00:00
parent 3322254d27
commit 9794095354
3 changed files with 55 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2008-04-08 Corinna Vinschen <corinna@vinschen.de>
* mount.cc (mount_info::from_fstab): Read user fstab files from
/etc/fstab.d/$USER to avoid user write access to /etc.
* postinstall: Use variables for filenames. Create /etc/fstab.d dir
with 01777 permissions.
2008-04-08 Corinna Vinschen <corinna@vinschen.de> 2008-04-08 Corinna Vinschen <corinna@vinschen.de>
* postinstall: Disable adding registry mounts to /etc/fstab for now. * postinstall: Disable adding registry mounts to /etc/fstab for now.

View File

@ -914,7 +914,7 @@ mount_info::from_fstab (bool user)
PWCHAR u = wcpcpy (w, L"\\etc\\fstab"); PWCHAR u = wcpcpy (w, L"\\etc\\fstab");
if (user) if (user)
sys_mbstowcs (wcpcpy (u, L"."), NT_MAX_PATH - (u - path), sys_mbstowcs (wcpcpy (u, L".d\\"), NT_MAX_PATH - (u - path),
cygheap->user.name ()); cygheap->user.name ());
debug_printf ("Try to read mounts from %W", path); debug_printf ("Try to read mounts from %W", path);
HANDLE h = CreateFileW (path, GENERIC_READ, FILE_SHARE_READ, &sec_none_nih, HANDLE h = CreateFileW (path, GENERIC_READ, FILE_SHARE_READ, &sec_none_nih,

View File

@ -10,6 +10,10 @@
# #
export PATH="/bin:$PATH" export PATH="/bin:$PATH"
SYSCONFDIR=/etc
FSTAB="${SYSCONFDIR}/fstab"
FSTABDIR="${SYSCONFDIR}/fstab.d"
DEVDIR=/dev DEVDIR=/dev
print_flags () print_flags ()
@ -22,21 +26,21 @@ print_flags ()
} }
# Create fstab file if it doesn't exist. # Create fstab file if it doesn't exist.
if [ -e "/etc/fstab" -a ! -f "/etc/fstab" ] if [ -e "${FSTAB}" -a ! -f "${FSTAB}" ]
then then
# Try to move # Try to move
mv -f "/etc/fstab" "/etc/fstab.orig" mv -f "${FSTAB}" "${FSTAB}.orig"
if [ -e "/etc/fstab" -a ! -f "/etc/fstab" ] if [ -e "${FSTAB}" -a ! -f "${FSTAB}" ]
then then
echo echo
echo "/etc/fstab is existant but not a file." echo "${FSTAB} is existant but not a file."
echo "Since this file is specifying the mount points, this might" echo "Since this file is specifying the mount points, this might"
echo "result in unexpected trouble. Please fix that manually." echo "result in unexpected trouble. Please fix that manually."
echo echo
fi fi
fi fi
if [ ! -e "/etc/fstab" ] if [ ! -e "${FSTAB}" ]
then then
# Set IFS to just a LF # Set IFS to just a LF
_OLD_IFS="$IFS" _OLD_IFS="$IFS"
@ -52,7 +56,7 @@ then
break break
fi fi
done done
cat > /etc/fstab << EOF cat > ${FSTAB} << EOF
# The file fstab contains descriptive information about the various file # The file fstab contains descriptive information about the various file
# systems. fstab is only read by programs, and not written; it is the # systems. fstab is only read by programs, and not written; it is the
# duty of the system administrator to properly create and maintain this # duty of the system administrator to properly create and maintain this
@ -144,12 +148,12 @@ EOF
# echo -n "${nat} ${psx} some_fs " # echo -n "${nat} ${psx} some_fs "
# print_flags $flags # print_flags $flags
# echo " 0 0" # echo " 0 0"
# fi >> /etc/fstab # fi >> ${FSTAB}
#done #done
#[ -z "$usr_bin" ] && #[ -z "$usr_bin" ] &&
echo "${CYGROOT//\\//}/bin /usr/bin ${FS_TYPE} binary 0 0" >> /etc/fstab echo "${CYGROOT//\\//}/bin /usr/bin ${FS_TYPE} binary 0 0" >> ${FSTAB}
#[ -z "$usr_lib" ] && #[ -z "$usr_lib" ] &&
echo "${CYGROOT//\\//}/lib /usr/lib ${FS_TYPE} binary 0 0" >> /etc/fstab echo "${CYGROOT//\\//}/lib /usr/lib ${FS_TYPE} binary 0 0" >> ${FSTAB}
#cygd="" #cygd=""
#prefix=$(regtool -q get "$key\cygdrive prefix") #prefix=$(regtool -q get "$key\cygdrive prefix")
@ -162,16 +166,47 @@ EOF
# echo -n "none ${psx} cygdrive " # echo -n "none ${psx} cygdrive "
# print_flags $flags # print_flags $flags
# echo ",user 0 0" # echo ",user 0 0"
#fi >> /etc/fstab #fi >> ${FSTAB}
#if [ -z "$cygd" ] #if [ -z "$cygd" ]
#then #then
echo "# This is default anyway:" >> /etc/fstab echo "# This is default anyway:" >> ${FSTAB}
echo "# none /cygdrive cygdrive binary,user 0 0" >> /etc/fstab echo "# none /cygdrive cygdrive binary,user 0 0" >> ${FSTAB}
#fi #fi
IFS="$_OLD_IFS" IFS="$_OLD_IFS"
fi fi
# Check for ${FSTABDIR} directory
if [ -e "${FSTABDIR}" -a ! -d "${FSTABDIR}" ]
then
# No mercy. Try to remove.
rm -f "${FSTABDIR}"
if [ -e "${FSTABDIR}" -a ! -d "${FSTABDIR}" ]
then
echo
echo "${FSTABDIR} is existant but not a directory."
echo "Please fix that manually."
echo
exit 1
fi
fi
# Create it if necessary
if [ ! -e "${FSTABDIR}" ]
then
mkdir -m 1777 "${FSTABDIR}"
if [ ! -e "${FSTABDIR}" ]
then
echo
echo "Creating ${FSTABDIR} directory failed."
echo "Please fix that manually."
echo
exit 1
fi
fi
# Check for ${DEVDIR} directory # Check for ${DEVDIR} directory
if [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ] if [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ]