Issue1856

classification
Title: Permission denied when writing to files under /sys (sysfs) directory
Type: Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: amak, fwierzbicki, halfie, jeff.allen, zyasoft
Priority: low Keywords:

Created on 2012-03-19.09:36:50 by halfie, last changed 2018-03-17.06:29:59 by jeff.allen.

Files
File name Uploaded Description Edit Remove
jyproc.py halfie, 2012-03-19.09:36:50 test script
sysfs.java halfie, 2012-03-19.12:08:39 Test Case in Java
Messages
msg6816 (view) Author: halfie (halfie) Date: 2012-03-19.09:36:49
I am unable to write to files under /sys (sysfs) directory using Jython 2.5.2

When I run the attached "jyproc.py" file, I get

Traceback (most recent call last):
  File "jyproc.py", line 4, in <module>
    f.write("1")
IOError: [Errno 13] Permission denied: '/sys/block/sdc/device/delete'

...

Same code runs fine under Python 2.7.2. 

$ jython -V
Jython 2.5.2

$ java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
msg6817 (view) Author: halfie (halfie) Date: 2012-03-19.12:08:38
Attaching similar program written in Java which works just fine. So it doesn't seem to be a Java problem but a Jython problem.
msg7750 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-25.20:28:22
Sorry for the slow response - can you tell me more about your platform? Mainly what os you are on and some details about how /sys (sysfs) is mounted etc?
msg7782 (view) Author: halfie (halfie) Date: 2013-02-26.04:30:33
I am running CentOS 6.3 64-bit which uses Linux 2.6.32.x kernel.

$ mount | grep sysfs 
sysfs on /sys type sysfs (rw)

$ java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.7.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Nothing fancy :)
msg7784 (view) Author: Alan Kennedy (amak) Date: 2013-02-26.08:32:47
Please can you run the following jython code on your system and report the results?

Thanks.

################
from java.io import BufferedWriter, FileWriter
import java.lang

if __name__ == "__main__":
    fileName = "/sys/block/sdb/device/delete"
    try:
        writer = BufferedWriter(FileWriter(fileName,True))
        writer.write("1")
        writer.close()
    except java.lang.Exception, e:
        e.printStackTrace()
################
msg9506 (view) Author: Jim Baker (zyasoft) Date: 2015-02-08.06:24:44
Any updates?
msg10556 (view) Author: Jim Baker (zyasoft) Date: 2015-12-28.17:46:50
Somewhat similar issue in #2358

We need to come up with a robust testing strategy, using some sort of emulation/virtualization. We normally don't expect tests to being doing something like the following: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Online_Storage_Reconfiguration_Guide/removing_devices.html Perhaps Docker can be used here?
msg11817 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-17.06:29:59
Now #2358 is closed, is this still a live issue?
History
Date User Action Args
2018-03-17 06:29:59jeff.allensetpriority: low
nosy: + jeff.allen
messages: + msg11817
2015-12-28 17:46:51zyasoftsetmessages: + msg10556
2015-02-08 06:24:44zyasoftsetnosy: + zyasoft
messages: + msg9506
2014-05-22 00:05:31zyasoftsetresolution: remind
2013-02-26 08:32:47amaksetmessages: + msg7784
2013-02-26 07:56:08amaksetnosy: + amak
2013-02-26 04:30:34halfiesetmessages: + msg7782
2013-02-25 20:28:22fwierzbickisetnosy: + fwierzbicki
messages: + msg7750
versions: + Jython 2.5, - 2.5.2
2012-03-19 12:08:39halfiesetfiles: + sysfs.java
messages: + msg6817
2012-03-19 09:36:50halfiecreate