LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 06-30-2011, 04:55 PM   #1
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
Dumb question about .xinitrc


Hi
I have Arch Linux and everything works fine
I have been googling around but i can't figure it out if .xinitrc should have executive rights. My .xinitrc works fine with executive rights or without but i am asking this "stupid" qustion just to be sure and to have a calm sleep

thx for your answer

Last edited by Shark82; 06-30-2011 at 05:01 PM.
 
Old 06-30-2011, 05:56 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
not really a stupid question, but you sorta answered your own question without knowing it.

if it works without, then it doesn't need it, in fact i would avoid giving exec privs to anything that works without them (security ya know)
 
1 members found this post helpful.
Old 06-30-2011, 06:02 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Configuration files do not generally need to be executable. The programs that import the settings from them just need to be able to read the file.
 
1 members found this post helpful.
Old 07-01-2011, 01:18 AM   #4
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Original Poster
Rep: Reputation: 3
Ok, thank you both for answers. For test i have created a new user and the file in new user's home hasn't got executive permission. So i conclude that doesn't need them

But he Ubuntu page have somewhat confused :
Quote:
Now make your X session script executable. To do this, type the following command into your terminal:

chmod +x ~/.xinitrc
https://wiki.ubuntu.com/CustomXSession

Last edited by Shark82; 07-01-2011 at 01:20 AM.
 
Old 07-01-2011, 08:30 AM   #5
Karl Godt
Member
 
Registered: Mar 2010
Location: Kiel , Germany
Distribution: once:SuSE6.2,Debian3.1, aurox9.2+3,Mandrake?,DSL? then:W7st,WVHB, #!8.10.02,PUPPY4.3.1 now:Macpup
Posts: 314

Rep: Reputation: 45
The security contains also the way a script gets executed I think :
In bash any "exit" inside a "source"ed script can make the parent exit , too .
Sourced scripts need a "return" if needed to not kill the parent (xinit) .

I think I read somewhere it would be "canonical" to make such configuration files executable and put a "#!/bin/sh" on top to make it possible to either execute the script or to source it .

Configuration files are also read by C-command(s) as described here :
http://www.suite101.com/content/c-tu...ommands-a20756
 
Old 07-01-2011, 11:49 AM   #6
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
I've just had a quick look at .bashrc and that's not executable. The question is, how is the file going to be used? If it just contains information that some script is going to utilise, then it doesn't need to be executable; if it is a script, it does. In general, I think the suffix -rc shows that a file isn't a script. You can't judge by the contents; my .bashrc contains commands like "export EDITOR=nano".
 
Old 07-01-2011, 12:14 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by DavidMcCann View Post
If it just contains information that some script is going to utilise, then it doesn't need to be executable; if it is a script, it does.
By "script" you mean "executed directly by the OS, without explicitly specifying an interpreter"?

Because I always thought that even if you don't give it executable priveleges, and explicitly pass it to an interpreter, than it's still called a script.
 
Old 07-01-2011, 01:08 PM   #8
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Original Poster
Rep: Reputation: 3
It is interesting, because i have copied .xinitrc from the /etc/skel and at the beggining it has #!/bin/sh so i tgought that has to have executive permission.
.xinitrc from skel:
Quote:
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi

# exec gnome-session
# exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
 
Old 07-02-2011, 11:44 AM   #9
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
Quote:
Originally Posted by MTK358 View Post
By "script" you mean "executed directly by the OS, without explicitly specifying an interpreter"?
By a script, I mean a simple program that runs with an interpreter, and that is a utility (or quick fix) rather than an application. Of course, the OS does not execute scripts; if you don't specify an interpreter, it passes them to your default shell interpreter.
 
Old 07-02-2011, 12:55 PM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by DavidMcCann View Post
By a script, I mean a simple program that runs with an interpreter, and that is a utility (or quick fix) rather than an application.
According to that definition of scripts, the idea that "scripts" need exe permissions and non-scripts don't is wrong.

Executable permissions are needed if the program is a true executable file or if the program is a script with a shebang line and is to be given directly to the OS as if it was an executable file, like this (using the exec system call):
Code:
execl("path/to/script-with-shebang-line", "script-with-shebang-line", NULL);
, or like this (from the shell):
Code:
$ path/to/script-with-shebang-line
.

Executable permissions are not needed if the file is passed as an argument to an interpreter executable, like this (using the exec system call):
Code:
execl("path/to/interpreter", "interpreter", "path/to/script", NULL);
, or like this (in the shell):
Code:
$ path/to/interpreter path/to/script
. Interpreters don't care if their source files are executable.
 
Old 07-02-2011, 01:07 PM   #11
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Original Poster
Rep: Reputation: 3
So, what about .xinitrc? Is executive permission needed?
 
Old 07-02-2011, 01:18 PM   #12
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Ehrm... xinitrc is your start-up file for X, as the name says x-init-rc...

But, where does that question come from? And...(more importantly) where do you want to get with that question? It is an init file, something else reads it. Arch uses (or better: the X) it to start up the DE (Gnome, XFCE,...), it is started at startx, in turn nudged by whatever is in inittab, mine is set to init3 - the inittab, however has a last line that starts (and sets it to respawn) the XDM for login. As this goes into "graphical" mode - the subsequent startx makes the info in xinitrc relevant, it gets read out and used to go into the required session, it says "exec gnome-session"

In short, xinitrc is read (not executed - so only read rights are needed, for the processes that need this info) by the X11 server, that gets started up by a line in inittab where a graphical login is requested.

Any X-troubles by the way???

Thor

Last edited by ButterflyMelissa; 07-02-2011 at 01:29 PM.
 
Old 07-02-2011, 01:23 PM   #13
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Original Poster
Rep: Reputation: 3
Hi Thor. It is just a question out of curiousity. I have copied my file from /etc/skel. As you can see above skeleton file has #!/bin/sh so that is why i automatically thought of the need for execution permission.

Beside this i am not experiencing any problem with X.
 
Old 07-02-2011, 01:41 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Thor_2.0 View Post
In short, xinitrc is read (not executed - so only read rights are needed, for the processes that need this info)
I doubt that startx itself reads .xinitrc directly. It's impossible to know if it's read or executed without looking at the startx source code, to see if it's executing .xinitrc or starting a shell instance and passing .xinitrc as an argument to it. Since it works without a shebang line, I bet that the latter is true (and thus executable permissions are not needed).
 
Old 07-02-2011, 01:49 PM   #15
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Original Poster
Rep: Reputation: 3
Actually when i do startx a do have some errors. The error is:

Quote:
xauth: (stdin):2: unknown command "1cadab1f1b0d45a75624788cdf44254d"

Last edited by Shark82; 07-02-2011 at 02:08 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I have a question about ~/.xinitrc planetsheinker Slackware 10 09-07-2005 09:20 AM
.xinitrc-question theonebeyond Linux - General 5 11-24-2004 10:10 AM
.xinitrc fluxbox question Abe_the_Man Linux - General 13 06-28-2004 07:25 AM
editing .xinitrc question bosewicht Linux - Newbie 1 04-04-2004 01:58 AM
.xinitrc question. Just trying to get one program to run hindenbergbaby Linux - General 2 02-21-2004 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration