Opening Kate while system is rooted in terminal gives a warning message as follows:
paul-Thinkcentre-M91p:~ # kate /etc/crypttab
THIS IS POTENTIALLY INSECURE!
To edit files as root please use:
SUDO_EDITOR=kwrite sudoedit <file>
paul-Thinkcentre-M91p:~ #
Kate GUI does then open the correct and expected file for editing. If I open Kate with the following
Kate opens a file with a very very strangely named file (having no similar name) for editing.
My questions for you is what is the preferred way to open Kate for a specific file in root and not in root? How serious is this warning? I understand not backing up the specific file first can be fatal. What is this warning all about?
paul@paul-Thinkcentre-M91p:~> man kwrite
No manual entry for kwrite
Possibly, man page is not installed, try online at: https://manpages.opensuse.org/kwrite
paul@paul-Thinkcentre-M91p:~>
Kwrite is a stripped down version of Kate, which of course means most developers will use Kate, whereas the average user might prefer Kwrite.
I get the warning message too when I’ve done an command line “su -l” to do root-oriented text editing stuff, but I’ve always ignored the message when using Kate as root. Others will no doubt be along to explain the warning with more clarity
Both, kate and kwrite are KDE applications. I actually wonder that kate even has a man page. For kwrite at least kwrite -h works.
Both are part of the same project, the help reference in kwrite links to https://kate-editor.org/ and see here: https://kate-editor.org/get-it/
I don’t know more about this.
However, since both are KDE (GUI) based, why starting them from the terminal? I assume you /are/ using KDE? In that case just use the starter, traditionlly “alt+F2” and type: kdesu kate /etc/crypttab. This also works from a terminal window with your regular user.
I wanted to for now briefly respond to this and am glad for the advice. “alt+F2” in KDE TW operating here does bring up the “starter” and then after passing: kdesue kate /etc/crypttab root privilege box comes up, after passing user password nothing/no new tab is displayed in the taskbar. I have attempted this also in a completely clear workspace. After a brief search on ‘kdesu kate’ I opened https://bbs.archlinux.org/viewtopic.php?id=225692 obviously it’s an older discussion and different OS though KDE is the desktop referred to and looks like at least in 2016 (kate and dolphin etc) have been adjusted to not be allowed to run as root anymore. Does this hold true with openSUSE I am wondering?
This is good information at least for me to be aware of now. When I open the “starter” then pass: kdesu -c "kate -b /etc/crypttab" I am able to then enter root password and “Kate” opens up /etc/crypttab as root. Also good to see that a bug report has been filed.
Is this considered a workaround? Can you say what -c -b and "" I think flags they are called are doing in this instance?
That’s easy … you can find it using kdesu --help at a CLI - for example:
:~> kdesu --help
...
Usage: kdesu [options] command
Runs a program with elevated privileges.
Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
--author Show author information.
--license Show license information.
--desktopfile <file name> The base file name of the desktop entry for this
application.
-c <command> Specifies the command to run as one string
-f <file> Run command under target uid if <file> is not
writable
-u <user> Specifies the target uid
-n Do not keep password
-s Stop the daemon (forgets all passwords)
-t Enable terminal output (no password keeping)
-p <prio> Set priority value: 0 <= prio <= 100, 0 is lowest
-r Use realtime scheduling
--noignorebutton Do not display ignore button
-i <icon name> Specify icon to use in the password dialog
-d Do not show the command to be run in the dialog
--attach <winid> Makes the dialog transient for an X app specified
by winid
--embed <winid> Embed into a window
Ok, I see -c in kdesu --help -c (is command and not flag), Can you for future reference. Tell me how to look more deeply into the -b command in kate -b /your/file/here ?
> kate --help
Usage: kate [options] [urls...]
Kate - Advanced Text Editor
Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
--author Show author information.
--license Show license information.
--desktopfile <file name> The base file name of the desktop entry for this
application.
-s, --start <session> Start Kate with a given session.
--startanon Start Kate with a new anonymous session, implies
'-n'.
-n, --new Force start of a new kate instance (is ignored if
start is used and another kate instance already has
the given session opened), forced if no parameters
and no URLs are given at all.
-b, --block If using an already running kate instance, block
until it exits, if URLs given to open.
-p, --pid <pid> Only try to reuse kate instance with this pid (is
ignored if start is used and another kate instance
already has the given session opened).
-e, --encoding <encoding> Set encoding for the file to open.
-l, --line <line> Navigate to this line.
-c, --column <column> Navigate to this column.
-i, --stdin Read the contents of stdin.
--tempfile The files/URLs opened by the application will be
deleted after use
Arguments:
urls Documents to open.
What is it like to upvote the bugreport? Again I ask about the two "" on each side of kdesu -c "kate -b /your/file/here" Is this for separate kdesu and kate ?
I would also like to ask you about what kdesu -c "kate -b /your/file/here" is called exactly? Is it called command?
Thanks for helping and this will be good for referencing.
Overwrote my last comment by accident and had to delete it…
Here again:
The “” marks the string which will be executed by kdesu -c
If you wouldn’t use the “”, kdesu -c would see the end of the command after kate, as blanks are not interpreted as part of the string (without “”).
A blank is the empty space between two chars/words…
Passing: kdesu -c kate -b /your/file/here without “” Is kate ignored then and -c and -b command used by kdesu basically creating a failed command so to say then?
kate -b /your/file/here is a “standalone” command which will open any text file in kate (as long as it is owned by your user).
To execute a string or a command via kdesu -c you need to tell kdesu what is all part of the string which needs to be executed. In this case kate -b /your/file/here. Thats why you use “” to tell kdesu -c that "kate -b /your/file/here" is the string. Everything between “” is interpreted as part of the string.
You can make some easy test yourself. If you have as example a song (mp3) on your HDD/SSD with a blank in the name.
Try to play it with VLC from terminal.
Will fail: vlc name with blanks.mp3
Will succeed and vlc will play the file:
Thanks for helping me understand this so it makes much more sense now.
paul@paul-Thinkcentre-M91p:~/airscan/trace> kate --help
Usage: kate [options] [urls...]
Kate - Advanced Text Editor
Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
--author Show author information.
--license Show license information.
--desktopfile <file name> The base file name of the desktop entry for this
application.
-s, --start <session> Start Kate with a given session.
--startanon Start Kate with a new anonymous session, implies
'-n'.
-n, --new Force start of a new kate instance (is ignored if
start is used and another kate instance already has
the given session opened), forced if no parameters
and no URLs are given at all.
-b, --block If using an already running kate instance, block
until it exits, if URLs given to open.
-p, --pid <pid> Only try to reuse kate instance with this pid (is
ignored if start is used and another kate instance
already has the given session opened).
-e, --encoding <encoding> Set encoding for the file to open.
-l, --line <line> Navigate to this line.
-c, --column <column> Navigate to this column.
-i, --stdin Read the contents of stdin.
--tempfile The files/URLs opened by the application will be
deleted after use
Arguments:
urls Documents to open.
paul@paul-Thinkcentre-M91p:~/airscan/trace>
-b, --block If using an already running kate instance, block
until it exits, if URLs given to open.
Can you help me understand what: -b, --block If using an already running kate instance, block
until it exits, if URLs given to open.
means a bit more? Perhaps more specifically my question block
until it exits, if URLs given to open.
Something having to do with URL meaning a web link of some sort?
To make it even better understandable for you, lets view again at the help files from kate and kdesu linked in comment 10 and comment 12.
kdesu --help
Usage: kdesu [options] command
kate --help
Usage: kate [options] [urls...]
It is required that the command part of kdesu [options] command is a string. That means if you only put kdesu -c kate -b /etc/crypttab, kdesu can’t interpret anything behind kate as it seems no part of the string (command):
But if you put kate -b /etc/crypttab into “”, kdesu can interpret this as complete string which needs to be interpreted in complete.
We are combining two “standalone” commands in this example case, and need to tell one of these commands what is part of the other command.
Sometimes it is hard to explain such basics for someone who is used to it since decades…
Maybe someone has a handy link for you which explains such command line basics better…
I was not looking closely enough. Is url in this instance meaning --block and -b is the option? I am understanding much better. I believe to review this before I respond again. Thanks for helping me with this because it will allow me to better understand how other programs like VLC can be run.