diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/mount.cc | 2 | ||||
-rwxr-xr-x | winsup/cygwin/postinstall | 59 |
3 files changed, 55 insertions, 13 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 14d63600a..5070c7267 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 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> + * postinstall: Disable adding registry mounts to /etc/fstab for now. 2008-04-07 Christopher Faylor <me+cygwin@cgf.cx> diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index ba6f42bb1..83d45d5de 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -914,7 +914,7 @@ mount_info::from_fstab (bool user) PWCHAR u = wcpcpy (w, L"\\etc\\fstab"); 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 ()); debug_printf ("Try to read mounts from %W", path); HANDLE h = CreateFileW (path, GENERIC_READ, FILE_SHARE_READ, &sec_none_nih, diff --git a/winsup/cygwin/postinstall b/winsup/cygwin/postinstall index 68ae132a6..829bb5feb 100755 --- a/winsup/cygwin/postinstall +++ b/winsup/cygwin/postinstall @@ -10,6 +10,10 @@ # export PATH="/bin:$PATH" +SYSCONFDIR=/etc +FSTAB="${SYSCONFDIR}/fstab" +FSTABDIR="${SYSCONFDIR}/fstab.d" + DEVDIR=/dev print_flags () @@ -22,21 +26,21 @@ print_flags () } # Create fstab file if it doesn't exist. -if [ -e "/etc/fstab" -a ! -f "/etc/fstab" ] +if [ -e "${FSTAB}" -a ! -f "${FSTAB}" ] then # Try to move - mv -f "/etc/fstab" "/etc/fstab.orig" - if [ -e "/etc/fstab" -a ! -f "/etc/fstab" ] + mv -f "${FSTAB}" "${FSTAB}.orig" + if [ -e "${FSTAB}" -a ! -f "${FSTAB}" ] then 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 "result in unexpected trouble. Please fix that manually." echo fi fi -if [ ! -e "/etc/fstab" ] +if [ ! -e "${FSTAB}" ] then # Set IFS to just a LF _OLD_IFS="$IFS" @@ -52,7 +56,7 @@ then break fi done - cat > /etc/fstab << EOF + cat > ${FSTAB} << EOF # The file fstab contains descriptive information about the various file # systems. fstab is only read by programs, and not written; it is the # duty of the system administrator to properly create and maintain this @@ -144,12 +148,12 @@ EOF # echo -n "${nat} ${psx} some_fs " # print_flags $flags # echo " 0 0" - # fi >> /etc/fstab + # fi >> ${FSTAB} #done #[ -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" ] && - echo "${CYGROOT//\\//}/lib /usr/lib ${FS_TYPE} binary 0 0" >> /etc/fstab + echo "${CYGROOT//\\//}/lib /usr/lib ${FS_TYPE} binary 0 0" >> ${FSTAB} #cygd="" #prefix=$(regtool -q get "$key\cygdrive prefix") @@ -162,16 +166,47 @@ EOF # echo -n "none ${psx} cygdrive " # print_flags $flags # echo ",user 0 0" - #fi >> /etc/fstab + #fi >> ${FSTAB} #if [ -z "$cygd" ] #then - echo "# This is default anyway:" >> /etc/fstab - echo "# none /cygdrive cygdrive binary,user 0 0" >> /etc/fstab + echo "# This is default anyway:" >> ${FSTAB} + echo "# none /cygdrive cygdrive binary,user 0 0" >> ${FSTAB} #fi IFS="$_OLD_IFS" 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 if [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ] |