Bug 171136 - Trying to add scripts not ending in ".sh" to run on "Pre-KDE startup" generates no warning
Summary: Trying to add scripts not ending in ".sh" to run on "Pre-KDE startup" genera...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: 4.1
Platform: openSUSE Unspecified
: NOR normal
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-16 07:52 UTC by Michael Liddle
Modified: 2015-08-20 14:43 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Liddle 2008-09-16 07:52:11 UTC
Version:            (using KDE 4.1.1)
Installed from:    SuSE RPMs

Bahaviour:
---------

- In the Autostart module, I add a script whose name does not end in ".sh", and set it to be run "Pre-KDE startup". 
- I log out and log in again. 
- KWrite opens with the script that I added. 
- A dialog appears saying that "KLauncher could not be reached via D-BUS etc..."
- I click OK, and am _immediately logged out_.
- Subsequent investigation showed that the script was instead added to the Autostart directory.

Expected:
--------

The documentation states that only scripts ending in ".sh" can be added to the Pre-KDE startup. 

This is an esoteric restriction in Unix and should either be removed, or when a user tries to add such a script it should fail, at add time, with a message explaining why...
Comment 1 Michael Liddle 2008-09-16 08:03:06 UTC
Sorry, version should be "Recent Snapshot or SVN checkout." My Bad...
Comment 2 Thomas Fischer 2008-10-11 13:31:13 UTC
I wrote a small patch that may resolve this bug and bug 170324. The patch is attached at bug 170324.
Comment 3 Russell 2010-05-13 23:11:54 UTC
I added a script to Autostart and selected "Pre-KDE startup". I closed System Settings and reopened. I went back to Autostart and the setting changed from "Pre-KDE startup" to "Startup".  I clicked on the drop down to change it *back* to "Pre-KDE startup" and I got a pop-up dialog box that said, "KDE only reads files with sh extensions for setting up the environment".

There are 3 problems here. First, the application changed my "Run On" setting without any notification. Second, the Autostart Module is missing the "OK, Apply, and Cancel" buttons at the button. Third, unix has no concept of file extension like some other OS (i.e.,Windows/DOS).  There is no guarantee that a file with a certain file name that might look like an extension, like ".sh", is a shell script. Unix uses other means. See man page for `file`.  

Environment:
  kdebase4: v4.3.5
  dist: OpenSUSE 11.2
Comment 4 Brian DeRocher 2010-06-01 23:54:27 UTC
I can confirm this.  I'm trying to establish ssh tunnels before kate starts up.  The control panel is acting weird, like not remembering that i selected Pre-KDE startup.
Comment 5 S. Christian Collins 2011-07-04 19:05:18 UTC
I believe this is related to bug #228795.  The systemsettings dialog is not moving the correct script to the shutdown folder.  Confirmed using KDE 4.6.4 on Kubuntu 11.04.
Comment 6 Jekyll Wu 2012-11-10 06:49:34 UTC
well, all those "fail to change startup type as expected" are really bug 228795, which I have just fixed.

The original title of this report is "Trying to add scripts not ending in ".sh" to run on "Pre-KDE startup" generates no warning ". Well, that is no longer the case for recent versions. A dialog will popup, saying "Only files with “.sh” extensions are allowed for setting up the environment". 

But I agree the ".sh" extension requirement is not good.   Actually, among the three types, only the "Pre-KDE startup" really requires shell scripts because those scripts are "sourced" by the startkde shell script. There is nothing wrong to use executable python/perl scripts for "Startup" and "Shutdown", as far as I understand.
Comment 7 Jekyll Wu 2012-11-10 09:50:49 UTC
Git commit 6eccde0a3638cea05142d69362c66265cbab0cbd by Jekyll Wu.
Committed on 10/11/2012 at 10:40.
Pushed by jekyllwu into branch 'KDE/4.9'.

Loose the requirement of script having .sh extention.

Now that warning only appears for "Pre-KDE" type. There is no technical
requirement of shell scripts for "Startup" and "Shutdown", let alone
that .sh extension.

Eventually, that .sh extension requirement should just go away. "Pre-KDE"
requires shell script (it is OK to be non-executable), that is all.

M  +1    -1    kcontrol/autostart/autostart.cpp

http://commits.kde.org/kde-workspace/6eccde0a3638cea05142d69362c66265cbab0cbd
Comment 8 Jekyll Wu 2012-11-11 12:52:04 UTC
I was kind of wrong.  That ".sh" extension requirement is necessary, because clearly the startkde script only care about shell scripts with .sh extension.

# Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
# (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
#
# This is where you can define environment variables that will be available to
# all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
# or eval `gpg-agent --daemon`.
# Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
#
# (see end of this file).
# For anything else (that doesn't set env vars, or that needs a window manager),
# better use the Autostart folder.

libpath=`kde4-config --path lib | tr : '\n'`

for prefix in `echo "$libpath" | sed -n -e 's,/lib[^/]*/,/env/,p'`; do
  for file in "$prefix"*.sh; do
    test -r "$file" && . "$file"
  done
done

So the current behavior of poping up a warning dialog is consistent with the requirement of startkde. 

The only problem left is that warning should appear before instead of after moving the file (change its startup type) , and the moving should be canceled.
Comment 9 David Edmundson 2015-08-20 14:43:21 UTC
There's a dialog as described in #7