Difference between pages "Run vlc as root" and "Context menus"

From Linuxintro
(Difference between pages)
imported>ThorstenStaerk
 
imported>ThorstenStaerk
(this is all work in progress)
 
Line 1: Line 1:
When starting [[vlc]] as root you will probably get the following [[error message]]:
+
When you right-click on your Linux desktop you get a context menu displayed. It looks like this:
VLC is not supposed to be run as root. Sorry.
 
If you need to use real-time priorities and/or privileged TCP ports
 
you can use vlc-wrapper (make sure it is Set-UID root and
 
cannot be run by non-trusted users first).
 
Here is how I change this behavior:
 
[[gdb]] /usr/bin/vlc
 
(gdb) info functions
 
All defined functions:
 
 
Non-debugging symbols:
 
[...]
 
0x0000000000400f40  geteuid
 
[...]
 
Let's break in the function to get the effective user identity:
 
(gdb) break geteuid
 
Breakpoint 1 at 0x400f40
 
Let's start the program to run till the first breakpoint:
 
(gdb) run
 
Starting program: /usr/bin/vlc
 
 
Breakpoint 1, 0x00007ffff71cfc70 in geteuid () from /lib64/libc.so.6
 
ok, let's trace the program one command at a time:
 
(gdb) stepi
 
0x00007ffff71cfc75 in geteuid () from /lib64/libc.so.6
 
(gdb) stepi
 
0x00007ffff71cfc77 in geteuid () from /lib64/libc.so.6
 
(gdb)
 
0x0000000000401103 in ?? ()
 
(gdb)
 
0x0000000000401105 in ?? ()
 
(gdb)
 
Ok, let's look at this program part with a disassembler:
 
[[objdump]] -d -M intel /usr/bin/vlc
 
[...]
 
  4010f9:      e8 32 0a 00 00          call  401b30 <unsetenv>
 
  4010fe:      e8 3d fe ff ff          call  400f40 <geteuid@plt>
 
  401103:      85 c0                  test  eax,eax
 
  401105:      0f 84 04 06 00 00      je    40170f <fflush@plt+0x66f>
 
  40110b:      be ca 1f 40 00          mov    esi,0x401fca
 
  401110:      bf 06 00 00 00          mov    edi,0x6
 
[...]
 
Wow, it seems as if 4010fe calls geteuid, 401103 prepares a conditional jump and 401105 jumps if equal somewhere. So we call a [[hexeditor]]:
 
okteta /usr/bin/vlc
 
and replace
 
0f 84 04 06 00 00
 
by some instructions to wait:
 
90 90 90 90 90 90
 
When calling vlc now as root, it does not abort :)
 
  
Also, once the following worked:
+
[[File:Snapshot-context-menu-kde-1.png]]
  sed -<abbr title="in-place edit in the file">i</abbr><abbr title="extended regular expressions">r</abbr> "s/\x0f\x84..../\x90\x90\x90\x90\x90\x90/g" vlc
+
 
 +
How to edit it highly depends on your desktop environment.
 +
 
 +
See /usr/share/kde4/services/plasma-containmentactions-contextmenu.desktop
 +
 
 +
  tweedleburg:~/.kde4/share/config # diff plasma-desktop-appletsrc~ plasma-desktop-appletsrc
 +
3d2
 +
< wheel:Vertical;NoModifier=switchdesktop
 +
tweedleburg:~/.kde4/share/config # cd /usr/share/kde4/services
 +
tweedleburg:/usr/share/kde4/services # grep -ir "switchdesktop" *
 +
plasma-containmentactions-switchdesktop.desktop:X-KDE-Library=plasma_containmentactions_switchdesktop
 +
plasma-containmentactions-switchdesktop.desktop:X-KDE-PluginInfo-Name=switchdesktop
 +
tweedleburg:/usr/share/kde4/services # grep -ir "contextmenu" *
 +
plasma-containmentactions-contextmenu.desktop:X-KDE-Library=plasma_containmentactions_contextmenu
 +
plasma-containmentactions-contextmenu.desktop:X-KDE-PluginInfo-Name=contextmenu
 +
plasma-containmentactions-minimalcontextmenu.desktop:X-KDE-Library=plasma_containmentactions_minimalcontextmenu
 +
plasma-containmentactions-minimalcontextmenu.desktop:X-KDE-PluginInfo-Name=minimalcontextmenu
 +
 
 +
= Questions =
 +
* why can't I
 +
plasmoidviewer contextmenu
 +
: while i can use the contextmenu in .kde4/share/config/plasma-desktop-appletsrc
 +
* why can't I use charselect in .kde4/share/config/plasma-desktop-appletsrc
 +
: while I can
 +
plasmoidviewer charselect
 +
* seems this is determined by the type. One has
 +
ServiceTypes=Plasma/ContainmentActions
 +
the other
 +
ServiceTypes=Plasma/Applet
 +
* hm... do ContainmentActions need an init function to work? And in case of javascript Applets, just the javascript code is executed and an init function is not needed?
 +
 
 +
= See also =
 +
* http://try-linux.blogspot.de/2013/02/editing-context-menu.html
 +
* http://www.kde-forum.org/artikel/20502/edit-the-right-click-menu.html
 +
* http://stackoverflow.com/questions/3962298/how-to-add-an-entry-to-gnomes-context-menu
 +
* http://kde-apps.org/content/show.php?content=117639
 +
* http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/GettingStarted

Revision as of 08:34, 26 February 2013

When you right-click on your Linux desktop you get a context menu displayed. It looks like this:

Snapshot-context-menu-kde-1.png

How to edit it highly depends on your desktop environment.

See /usr/share/kde4/services/plasma-containmentactions-contextmenu.desktop

tweedleburg:~/.kde4/share/config # diff plasma-desktop-appletsrc~ plasma-desktop-appletsrc
3d2
< wheel:Vertical;NoModifier=switchdesktop
tweedleburg:~/.kde4/share/config # cd /usr/share/kde4/services
tweedleburg:/usr/share/kde4/services # grep -ir "switchdesktop" *
plasma-containmentactions-switchdesktop.desktop:X-KDE-Library=plasma_containmentactions_switchdesktop
plasma-containmentactions-switchdesktop.desktop:X-KDE-PluginInfo-Name=switchdesktop
tweedleburg:/usr/share/kde4/services # grep -ir "contextmenu" *
plasma-containmentactions-contextmenu.desktop:X-KDE-Library=plasma_containmentactions_contextmenu
plasma-containmentactions-contextmenu.desktop:X-KDE-PluginInfo-Name=contextmenu
plasma-containmentactions-minimalcontextmenu.desktop:X-KDE-Library=plasma_containmentactions_minimalcontextmenu
plasma-containmentactions-minimalcontextmenu.desktop:X-KDE-PluginInfo-Name=minimalcontextmenu

Questions

  • why can't I
plasmoidviewer contextmenu
while i can use the contextmenu in .kde4/share/config/plasma-desktop-appletsrc
  • why can't I use charselect in .kde4/share/config/plasma-desktop-appletsrc
while I can
plasmoidviewer charselect
  • seems this is determined by the type. One has
ServiceTypes=Plasma/ContainmentActions

the other

ServiceTypes=Plasma/Applet
  • hm... do ContainmentActions need an init function to work? And in case of javascript Applets, just the javascript code is executed and an init function is not needed?

See also