Short question:
Where are default permissions and ownership for removable media in openSUSE 12.1 ?
Long question:
Problem description:
-
A PHP script reads “/media” folder contents, searches for images and copies them. i.e. USB pendrives, DVD, CD.
-
The PHP script works fine in two different machines with openSUSE 11.3 (Laptop HP G62 and desktop processor Pentium D)
-
Desktop machine was upgraded to openSUSE 12.1 and script stopped working.
-
After analysis, I realized is a matter or permissions. openSUSE mounts removable media in “/media” and assigns ownership and permissions. But this works different for each one:
Permissions Ownership
OS Owner Group Everyone Owner Group
openSUSE 11.3 Read only Read only Read only myuser root
openSUSE 12.1 Read only Forbidden Forbidden myuser users
- PHP script runs as ” wwwrun / www”, so i need to change default permissions and ownership in order to read /media folder.
Troubleshooting history:
-
Except for the info of hard drives, the rest is identical in both /etc/fstab (openSUSE 11.3 vs 12.1):
… HD mounting conf …
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0 -
Partial ouput of “mount” command in openSUSE 12.1
(last two lines with info of removable media)
…
/dev/sdc1 on /media/MYPENDRIVE_USB type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0022,dmask=0077,codepage=cp437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,errors=remount-ro,uhelper=udisks)
/dev/sr0 on /media/MYIMAGES_DVD type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks) -
First try to workaround: fstab
If I create folders (as root) /media/usb and /media/dvd and add these lines to /etc/fstab :
/dev/sdc1 /media/usb auto user,noauto,exec,utf8 0 0
/dev/sr0 /media/dvd auto user,noauto,exec,utf8 0 0
DVD and USB Pendrive mount OK:
Permissions Ownership
Device Owner Group Everyone Owner Group
DVD Read only Read only Read only root root
USB RW only Read only Read only myuser root
“mount” output:
/dev/sr0 on /media/dvd type iso9660 (ro,nosuid,nodev,relatime,utf8,user=myuser)
/dev/sdc1 on /media/usb type vfat (rw,nosuid,nodev,relatime,uid=1000, fmask=0022, dmask=0022, codepage=cp437, iocharset=iso8859-1,shortname=mixed,utf8, errors=remount-ro,user=myuser)
BUT after RESTART, all folders inside /media are ERASED.
If I try to mount again, dolphin says “mounting point doesnt exist” and I should create again /dvd and /usb inside /media.
- Second try to workaround: permission files for udev
I’ve learned that openSUSE 12.1 uses udev instead of HAL, and it follows rules written in those particular files to mount devices.
After several days googling, ctr+f and becoming bold, I didnt found where are default values for permissions and ownership of removable media. So, where are they ?
PD: Attached are some rules of my openSUSE 12.1
(Do you see it? Please let me know)
contents of /etc/udev/udev.conf :
udev_log=“err”
contents of /etc/udev/rules.d/70-persistent-cd.rules :
(without comments)
SUBSYSTEM==“block”, ENV{ID_CDROM}=="?", ENV{ID_PATH}==“pci-0000:00:1f.1-scsi-0:0:1:0”, SYMLINK+=“cdrom”, ENV{GENERATED}=“1”
SUBSYSTEM==“block”, ENV{ID_CDROM}=="?", ENV{ID_PATH}==“pci-0000:00:1f.1-scsi-0:0:1:0”, SYMLINK+=“cdrw”, ENV{GENERATED}=“1”
SUBSYSTEM==“block”, ENV{ID_CDROM}=="?", ENV{ID_PATH}==“pci-0000:00:1f.1-scsi-0:0:1:0”, SYMLINK+=“dvd”, ENV{GENERATED}=“1”
SUBSYSTEM==“block”, ENV{ID_CDROM}=="?", ENV{ID_PATH}==“pci-0000:00:1f.1-scsi-0:0:1:0”, SYMLINK+=“dvdrw”, ENV{GENERATED}=“1”
contents of /lib/udev/rules.d/60-cdrom_id.rules
(without comments)
ACTION==“remove”, GOTO=“cdrom_end”
SUBSYSTEM!=“block”, GOTO=“cdrom_end”
KERNEL!=“sr[0-9]|xvd”, GOTO=“cdrom_end”
ENV{DEVTYPE}!=“disk”, GOTO=“cdrom_end”
KERNEL==“sr[0-9]", ENV{ID_CDROM}=“1”
ENV{DISK_EJECT_REQUEST}=="?”, RUN+=“cdrom_id --eject-media $tempnode”, GOTO=“cdrom_end”
IMPORT{program}=“cdrom_id --lock-media $tempnode”
LABEL=“cdrom_end”
Partial content of ** /lib/udev/rules.d/50-udev-default.rules**
(just where sr* appears, sr* = my dvd)
…
cdrom
SUBSYSTEM==“block”, KERNEL==“sr[0-9]", SYMLINK+=“scd%n”, GROUP=“cdrom”
SUBSYSTEM==“scsi_generic”, SUBSYSTEMS==“scsi”, ATTRS{type}==“4|5”, GROUP=“cdrom”
KERNEL=="pktcdvd[0-9]”, GROUP=“cdrom”
KERNEL==“pktcdvd”, GROUP=“cdrom”
…
content of /lib/udev/rules.d/75-cd-aliases-generator.rules
these rules generate rules for the /dev/{cdrom,dvd,…} symlinks
the “path” of usb/ieee1394 devices changes frequently, use “id”
ACTION==“add”, SUBSYSTEM==“block”, SUBSYSTEMS==“usb|ieee1394”, ENV{ID_CDROM}=="?", ENV{GENERATED}!="?",
PROGRAM=“write_cd_rules by-id”, SYMLINK+="%c", GOTO=“persistent_cd_end”
ACTION==“add”, SUBSYSTEM==“block”, ENV{ID_CDROM}=="?", ENV{GENERATED}!="?", PROGRAM=“write_cd_rules”, SYMLINK+="%c"
LABEL=“persistent_cd_end”
inside /etc/permissions (easy | local | paranoid | secure) there are not rules for /media
Albert