Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-04-01 Thread Anubhav Yadav
> Works For Me (tm).

Thanks! It Worked! :)


-- 
Regards,
Anubhav Yadav
Imperial College of Engineering and Research,
Pune.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/ca+jf9ahepinxcuhaq8ej7xtgmthfvxrkfktuy1su-oqhshq...@mail.gmail.com



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-31 Thread Andrei POPESCU
On Ma, 01 apr 14, 02:37:43, Anubhav Yadav wrote:
> 
> And assuming that I have my .profile set up with my PATH variable that I want 
> to
> use, I can create a ~/.xsessionrc and just source ~/.profile in it?
> That should work right?

Works For Me (tm).

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
http://nuvreauspam.ro/gpg-transition.txt


signature.asc
Description: Digital signature


Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-31 Thread Anubhav Yadav
> Don't know what rvm is, but I'm quite sure it didn't create your
> ~/.profile.

rvm is ruby version manager[1]. I installed it recently when I started
learning ruby on rails.

> But it did change yours. I don't like it when programs mess with my
> files.

That's what, Did you see how i got so many repetitions in my $PATH.
At this moment if I just echo $PATH and place each directory on one line,
this is the repetition that I get:

/home/neo1691/bin  [*]
:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin
/home/neo1691/.rvm/gems/ruby-2.0.0-p451@global/bin
/home/neo1691/.rvm/rubies/ruby-2.0.0-p451/bin
/usr/local/bin
/usr/bin
/bin
/usr/local/games
/usr/games
/home/neo1691/.rvm/bin  [**]
/home/neo1691/bin  [*]
/home/neo1691/.rvm/bin  [**]
/home/neo1691/.rvm/bin  [**]

There you see the repetitions. I am really concerned about that.

> Sorry, my mistake, I meant ~/.profile. ~/.environment is where I keep
> environment variables and I source it from ~/.profile.

That is a really good idea. But I loved the idea of .profile

> If I recall correctly lightdm does not source ~/.profile, so I do it in
> ~/.xsessionrc.

So I need to create this one.

> The logical place for that would be ~/.profile (or a file sourced in
> ~/.profile to not clutter it), since that should be read on login.

So the practice is to store all your variables in ~/.profile?

> Except that it's not read by some display managers so I had to use
> ~/.xsessionrc for that.

And assuming that I have my .profile set up with my PATH variable that I want to
use, I can create a ~/.xsessionrc and just source ~/.profile in it?
That should work right?

[1]http://www.rvm.io
-- 
Regards,
Anubhav Yadav
Imperial College of Engineering and Research,
Pune.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/ca+jf9agpxsnda_vxxlsgm5n1l4psg+6shrymownpqdolo6k...@mail.gmail.com



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-31 Thread Andrei POPESCU
On Ma, 01 apr 14, 01:38:43, Anubhav Yadav wrote:
> > The default ~/.profile on Debian already has:
> >
> > # set PATH so it includes user's private bin if it exists
> > if [ -d "$HOME/bin" ] ; then
> > PATH="$HOME/bin:$PATH"
> > fi
> >
> 
> I think I am really messed up in that situation. If I run 'echo $PATH'
> in a terminal session then this is the output that I get:
> 
> /home/neo1691/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@global/bin:/home/neo1691/.rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/neo1691/.rvm/bin:/home/neo1691/bin:/home/neo1691/.rvm/bin:/home/neo1691/.rvm/bin
> 
> As you can see there is a lot of repetition over there.
> 
> So to be precise, I first used my ~/.bashrc file to export the PATH variable.
> export PATH=${PATH}:/home/neo1691/bin
> 
> I remember that when I did this, there was no file called .profile in my home
> directory. As I can see now, there exists one maybe because I installed rvm
> and maybe rvm created a .profile

Don't know what rvm is, but I'm quite sure it didn't create your 
~/.profile.
 
[sni[

> PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

But it did change yours. I don't like it when programs mess with my 
files.

> I also saw that there is a  ~/.bash_profile whose contents are
> 
> [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default 
> .profile
> 
> 
> [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
> Load RVM into a shell session *as a function*

But this one looks like created by rvm.

> > Now you just have to make sure whatever method you use to start X is
> > also sourcing ~/.environment.
> 
> There is no such file called ~/.environment
 
Sorry, my mistake, I meant ~/.profile. ~/.environment is where I keep 
environment variables and I source it from ~/.profile.

> Now I would really like to know as to what is the best
> practice to export a PATH variable?
 
That's a complicated question and depends a lot on what software you 
use.

> I mean as a linux user, I should know what happens when the
> operating system boots? What files are read? What are the uses of
> .xsession?
> .xinitrc?
> .profile?
> .bash_profile?
> .environment?

Scratch this one.

> /etc/X11/Xsession?

You forgot .xsessionrc :p

> And what changes when I use lightdm to startup my system?

If I recall correctly lightdm does not source ~/.profile, so I do it in 
~/.xsessionrc.

> And what again changes if I install replace my default shell
> from bash to zsh?

No idea, never used zsh.

> Right now what is happening is that I am not able to run the
> script i3exit with i3 window manager?
> 
> If I run this command:
> `tr '\0' '\n'  
> I get the output as:
> PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
> 
> And there is no mention of my local bin directory (~/bin)
> 
> So please guide me in this regards!

My way is to keep any environment variables I need to set/change in one 
place only and make sure it's used everywhere (i.e. console and X).

The logical place for that would be ~/.profile (or a file sourced in 
~/.profile to not clutter it), since that should be read on login.

Except that it's not read by some display managers so I had to use 
~/.xsessionrc for that.

Hope this explains,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
http://nuvreauspam.ro/gpg-transition.txt


signature.asc
Description: Digital signature


Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-31 Thread Anubhav Yadav
> The default ~/.profile on Debian already has:
>
> # set PATH so it includes user's private bin if it exists
> if [ -d "$HOME/bin" ] ; then
> PATH="$HOME/bin:$PATH"
> fi
>

I think I am really messed up in that situation. If I run 'echo $PATH'
in a terminal session then this is the output that I get:

/home/neo1691/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@global/bin:/home/neo1691/.rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/neo1691/.rvm/bin:/home/neo1691/bin:/home/neo1691/.rvm/bin:/home/neo1691/.rvm/bin

As you can see there is a lot of repetition over there.

So to be precise, I first used my ~/.bashrc file to export the PATH variable.
export PATH=${PATH}:/home/neo1691/bin

I remember that when I did this, there was no file called .profile in my home
directory. As I can see now, there exists one maybe because I installed rvm
and maybe rvm created a .profile

Here are the contents of my ~/.profile

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

I also saw that there is a  ~/.bash_profile whose contents are

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*


> Now you just have to make sure whatever method you use to start X is
> also sourcing ~/.environment.
>

There is no such file called ~/.environment

> Depends on what you want to achieve. Because you put $HOME/bin at the
> end of $PATH (instead of in front as ~/.environment does) a script with
> the same name in one of the other directories will take precedence over
> yours, which may or may not be what you want.

I created the script i3exit, and I believe that there is no such other script
by that name in the system

> [1] according to apt-file there is no 'i3exit' file in Debian.
Yes thats right!

Now I would really like to know as to what is the best
practice to export a PATH variable?

I mean as a linux user, I should know what happens when the
operating system boots? What files are read? What are the uses of
.xsession?
.xinitrc?
.profile?
.bash_profile?
.environment?
/etc/X11/Xsession?

And what changes when I use lightdm to startup my system?

And what again changes if I install replace my default shell
from bash to zsh?

Right now what is happening is that I am not able to run the
script i3exit with i3 window manager?

If I run this command:
`tr '\0' '\n' https://lists.debian.org/ca+jf9afckosmpcpo0gj5ed_g2ctg06zuiik5m38e7pbeenq...@mail.gmail.com



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-31 Thread Andrei POPESCU
On Du, 30 mar 14, 16:44:13, Anubhav Yadav wrote:
> This script is stored in home/neo1691/bin/ directory and the directory
> is added in the PATH variable by adding   'export
> PATH=${PATH}:/home/neo1691/bin' in my .~/.bashrc file
... 
> 2) Is exporting the PATH variable like I had did is the correct way to
> add my directory to PATH,

The default ~/.profile on Debian already has:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

Now you just have to make sure whatever method you use to start X is 
also sourcing ~/.environment.

> if I want the other processes to also access the scripts in
> that folder?

Depends on what you want to achieve. Because you put $HOME/bin at the 
end of $PATH (instead of in front as ~/.environment does) a script with 
the same name in one of the other directories will take precedence over 
yours, which may or may not be what you want.

This is not a problem in your particular case[1], but might bite you 
when you're trying to override a system script or binary with your own.

[1] according to apt-file there is no 'i3exit' file in Debian.

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
http://nuvreauspam.ro/gpg-transition.txt


signature.asc
Description: Digital signature


Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-30 Thread Anubhav Yadav
Yes that worked! Thanks a lot!


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/ca+jf9ah0b+swn6f3+frzy95jbwt8l-2rru_bfwpjju3ut2y...@mail.gmail.com



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-30 Thread Anubhav Yadav
> That is your problem: You have configured sudo to allow you to run
> i3exit as root.
>
> But you don't. You run i3exit as yourself (without sudo), and IT then
> uses "sudo pm-suspend" (and others).
>
> Two possible ways forward:
>
> - Call it using "sudo i3exit" and remove the calls to sudo from inside
>   the script
>
> - Call it as yourself (= just "i3exit") and give yourself the
>   privileges to run "reboot", "halt" and others as sudo.
>
> Hope this helps

Hi basically I just want i3exit to run without asking any password, as I will
be using this script to be executed by i3.

So I guess your second option will suit me. If I do something like this:

 neo1691 ALL=(ALL) ALL, NOPASSWD: /usr/sbin/pm-suspend, /usr/sbin/pm-hibernate
-- 
Regards,
Anubhav Yadav
Imperial College of Engineering and Research,
Pune.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/CA+Jf9AHoeT+=wHZ=zrrupdcqgcyq2mwovq6gy+mm0tec2dy...@mail.gmail.com



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-30 Thread Karl E. Jorgensen
Hi

On Sun, Mar 30, 2014 at 04:44:13PM +0530, Anubhav Yadav wrote:
> Hi I have created a script called i3exit that allows me to suspend or
> hibernate my laptop without having to exit my i3wm thus allowing me to
> save my  work.
> 
> Here are the contents of my script:
> 
> #!/bin/sh
> lock() {
> i3lock
> }
> 
> case "$1" in
> lock)
> i3lock -d -i /home/neo1691/.i3/i3lock_screen.png -n
> ;;
> logout)
> i3-msg exit
> ;;
> suspend)
> sudo pm-suspend
> ;;
> hibernate)
> sudo pm-hibernate
> ;;
> reboot)
> sudo reboot
> ;;
> shutdown)
> sudo halt
> ;;
> *)
> echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
> exit 2
> esac
> 
> exit 0
> 
> This script is stored in home/neo1691/bin/ directory and the directory
> is added in the PATH variable by adding   'export
> PATH=${PATH}:/home/neo1691/bin' in my .~/.bashrc file
> 
> I used sudo visudo to edit the /etc/sudoers file and added this line at the 
> end:
>  neo1691 ALL=(ALL) ALL, NOPASSWD: /home/neo1691/bin/i3exit
> 
> After a restart when I run 'i3exit suspend' from my terminal, I am
> still asked for my password.

That is your problem: You have configured sudo to allow you to run
i3exit as root.

But you don't. You run i3exit as yourself (without sudo), and IT then
uses "sudo pm-suspend" (and others).

Two possible ways forward:

- Call it using "sudo i3exit" and remove the calls to sudo from inside
  the script

- Call it as yourself (= just "i3exit") and give yourself the
  privileges to run "reboot", "halt" and others as sudo.

Hope this helps
-- 
Karl E. Jorgensen


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20140330120508.GI26574@hawking



Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-30 Thread Linux-Fan
On 03/30/2014 01:14 PM, Anubhav Yadav wrote:
> Hi I have created a script called i3exit that allows me to suspend or
> hibernate my laptop without having to exit my i3wm thus allowing me to
> save my  work.
> 
> Here are the contents of my script:

[...]

> This script is stored in home/neo1691/bin/ directory and the directory
> is added in the PATH variable by adding   'export
> PATH=${PATH}:/home/neo1691/bin' in my .~/.bashrc file
> 
> I used sudo visudo to edit the /etc/sudoers file and added this line at the 
> end:
>  neo1691 ALL=(ALL) ALL, NOPASSWD: /home/neo1691/bin/i3exit
> 
> After a restart when I run 'i3exit suspend' from my terminal, I am
> still asked for my password.
> 
> To sum it up here are the problems that I want to solve:
> 1) How can I run the script without asking for a password?
> 2) Is exporting the PATH variable like I had did is the correct way to
> add my directory to PATH, if I want the other processes to also access
> the scripts in
> that folder?
> 
> Thanks!

Have you already considered what I suggested in
https://lists.debian.org/debian-user/2014/03/msg01409.html
?

-- 
http://masysma.ohost.de/



signature.asc
Description: OpenPGP digital signature


Unable to execute a script without asking for sudo password, even after editing sudoers file.

2014-03-30 Thread Anubhav Yadav
Hi I have created a script called i3exit that allows me to suspend or
hibernate my laptop without having to exit my i3wm thus allowing me to
save my  work.

Here are the contents of my script:

#!/bin/sh
lock() {
i3lock
}

case "$1" in
lock)
i3lock -d -i /home/neo1691/.i3/i3lock_screen.png -n
;;
logout)
i3-msg exit
;;
suspend)
sudo pm-suspend
;;
hibernate)
sudo pm-hibernate
;;
reboot)
sudo reboot
;;
shutdown)
sudo halt
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac

exit 0

This script is stored in home/neo1691/bin/ directory and the directory
is added in the PATH variable by adding   'export
PATH=${PATH}:/home/neo1691/bin' in my .~/.bashrc file

I used sudo visudo to edit the /etc/sudoers file and added this line at the end:
 neo1691 ALL=(ALL) ALL, NOPASSWD: /home/neo1691/bin/i3exit

After a restart when I run 'i3exit suspend' from my terminal, I am
still asked for my password.

To sum it up here are the problems that I want to solve:
1) How can I run the script without asking for a password?
2) Is exporting the PATH variable like I had did is the correct way to
add my directory to PATH, if I want the other processes to also access
the scripts in
that folder?

Thanks!

-- 
Regards,
Anubhav Yadav
Imperial College of Engineering and Research,
Pune.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/CA+Jf9AEHK3t-OocZbsJLvKMcE8Y8Q7xRreG98V=dtzcbmes...@mail.gmail.com