Posts: 1,028
SamK
Joined: 21 Aug 2011
#1
When right-clicking on a text file owned by root, antiX-13.1 displays an option Edit As Root. This is a useful feature, but it does not work as currently implemented. An error message is generated Failed to execute child process...Edit As Root (Permission denied).

It can be made to work as follows.


Remove the Non-Working Entry from the Right-Click Menu
  1. Move the file
    /home/USERNAME/config/rox.sourceforge.net/SendTo/Edit As Root
    to the root of your home directory.
    Alternatively, delete it as it is not required.

Replace the Non-Working File
  1. Download the attached file edit-as-root.sh.zip
  2. As root extract it from the zip archive to /usr/local/bin/edit-as-root.sh

Set Up the Right Click Menu in ROX-Filer
To ROX an executable script and a configuration file are two different types of text file. The following steps create a context sensitive entry for each of them. This approach ensures that the entry is only displayed when a text file is highlighted in ROX-Filer and hidden when a different file type is selected.

Do the following as your normal user in ROX-Filer
  1. Create a two hidden directories in /home/USERNAME/.config/rox.sourceforge.net/SendTo/
    .application_x-shellscript
    .text_plain
  2. Open the directory .application_x-shellscript
  3. Drag-n-drop /usr/local/bin/edit-as-root.sh to it and create a symlink
  4. Right-Click on the symlink-->Rename it Edit as root (i.e. no hyphens or .sh)
  5. Right-Click on the symlink-->Set icon. Select Only for the file...
  6. Drag-n-drop the icon file /usr/share/pixmaps/leafpad.png to the set icon box
  7. Open the directory .text_plain. Repeat steps 3 to 6 inclusive.
Screen shot showing text file owned by root highlighted in ROX-Filer with the right-click menu open
Screen shot showing text file owned by root highlighted in ROX-Filer with the right-click menu open
anticapitalista
Posts: 5,955
Site Admin
Joined: 11 Sep 2007
#2
I can't check for antiX-13.1 as I'm currently runing antiX-13 live from a usb stick, and the edit as root works ok here.
Posts: 1,028
SamK
Joined: 21 Aug 2011
#3
anticapitalista wrote:I can't check for antiX-13.1 as I'm currently runing antiX-13 live from a usb stick, and the edit as root works ok here.
I don't have a version 13.0 left here so can't try it.

I have just tried an installed antiX-12-Full and it works OK on that. I have seen the failure on two different 13.1 systems. One is elsewhere as it belongs to someone else so cannot be used for elimination purposes.

I will see if I can find a possible cause as the error is consistent on the test rig.

On a tangential note, might it be better to put executable scripts in /usr/local/bin and symlink to ~/.config/rox.sourceforge.net/SendTo/?



Edit
I may have found something.
Changing the ownership of ~/.config/rox.sourceforge.net/SendTo/.text_plain/Edit As Root affects whether the error message is obtained. When it is owned by the user all is OK. When it is owned by root the error is seen. Perhaps someone running an installed version of 13.1 might confirm this.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#4
I have a default installation of antix 13.1 set up fresh, no changes at all to the system.

I tried opening /etc/group and"edit as root" worked as expected. ~/.config/rox.sourceforge.net/SendTo/.text_plain/Edit As Root is owned by the user. changing the ownership to root: root (user: group) did not affect its operation and no error messages were obtained.
Posts: 1,028
SamK
Joined: 21 Aug 2011
#5
dolphin_oracle wrote:I have a default installation of antix 13.1 set up fresh, no changes at all to the system.

I tried opening /etc/group and"edit as root" worked as expected. ~/.config/rox.sourceforge.net/SendTo/.text_plain/Edit As Root is owned by the user. changing the ownership to root: root (user: group) did not affect its operation and no error messages were obtained.
Thanks that provided another piece of the puzzle. I too created a fresh install (testrig2) and obtain the same result as you, i.e. the default Edit As Root is able to work on files owned by root.


On testrig2 the ownership of
~/.config/rox.sourceforge.net/SendTo/.text_plain/Edit As Root
is builder:users. A minor point but should this be builder:builder?. The latter reflects the ownership ROX creates when symlinks are used rather than the script itself.

On testrig1 Edit As Root is owned by root. Additionally, the executable bit is not set for group or other. In this state the error message is generated. Changing the ownership to USER clears the problem as reported earlier. I am completely unaware of how this occurred.

On testrig2 the permissions on Edit As Root are rwxr-xr-x. When the more usual ROX symlink method is used the permissions are rwxrwxrwx.



An additional issue is now seen using the default Edit As Root. When the text file does not contain spaces it works as expected. When spaces are present it fails. Perhaps someone might confirm the following.

Diagnostic Test
  1. Create two identical plain text files containing"lorem ipsum"
  2. Name one"testfile1.txt", the other"test file 1.txt"
  3. Open each in turn via Edit As Root
Result
  1. testfile1.txt displays the expected text
  2. test file 1.txt displays an empty file
The problem seems to relate to the use of $1 in the default script. The script attached to my opening post uses"$@" to overcome the issue.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#6
I can confirm your results with the"testfile1.txt" vs."test file 1.txt". rox edit as root opens a new"text" file called test in the second case.