You are not logged in.

#1 2013-06-11 20:03:41

murukesh
Member
Registered: 2013-06-11
Posts: 18

[solved] netctl without sudo

netctl works fine, but I'd like to start it after login, instead of during boot. netctl-auto fails with some permission problems. netctl uses sudo, I think. So is there a way I can get it to start after boot, perhaps by adding it to my xinitrc? Or should I consider some other tool, like wicd?

Last edited by murukesh (2013-06-12 05:34:21)

Offline

#2 2013-06-11 20:38:56

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,156

Re: [solved] netctl without sudo

Why do you think it uses sudo?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-06-11 20:51:41

murukesh
Member
Registered: 2013-06-11
Posts: 18

Re: [solved] netctl without sudo

Because when I run it manually, this happens:

[bro3886@~] $ netctl start belkin
[sudo] password for bro3886: 
[bro3886@~] $

Offline

#4 2013-06-11 20:56:35

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [solved] netctl without sudo

Regardless of the utility, network operations require root privileges. networkmanager and wicd handle this by running a daemon as root, and an applet as user. netctl handles it by requiring you to use root privileges. smile

If you want to run it within a user session, you will have to use sudo - but to be clear, netctl does not use sudo by default. The response you posted comes from your sudo configuration, not from netctl.

Offline

#5 2013-06-11 21:03:17

murukesh
Member
Registered: 2013-06-11
Posts: 18

Re: [solved] netctl without sudo

Ah.
I'm not that familiar with the sudo config, but if I were to add a NOPASSWD line in sudoers for netctl, it'd work fine?

Offline

#6 2013-06-11 21:51:13

murukesh
Member
Registered: 2013-06-11
Posts: 18

Re: [solved] netctl without sudo

Nope. Adding a NOPASSWD line to sudoers didn't help. Now I get this error:

[bro3886@~] $ netctl start belkin
sudo: sorry, you are not allowed to preserve the environment
code 1

I should sleep on this.

Offline

#7 2013-06-11 21:54:04

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] netctl without sudo

Instead of sleeping on it, how about you read the documentation?  I think that might be the better plan here.  Both sudo and its configuration file, visudo, have ver well dosumented man pages.  Sleeping is not going to bring this information to you I don't think.

Offline

#8 2013-06-11 22:59:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,341
Website

Re: [solved] netctl without sudo

Meditating might also help ... or praying, consulting a shaman, starring into tea leaves.

wink


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2013-06-12 00:35:23

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] netctl without sudo

At least if you talk to a shaman, and he is a shaman/sys admin, then maybe you might actually get an answer...

Offline

#10 2013-06-12 03:00:05

dag
Member
From: US
Registered: 2013-01-20
Posts: 216

Re: [solved] netctl without sudo

funny but sleep may help if he has been working on it a while and needs eyes and mind that is fresh.

the real question is what would be the purpose of running it as a user and more importantly why. it seems to me it would put all kinds of security issues. why not put in your bash file something like alias

wifi='sudo wifi-menu'

or use netctl and disable all profiles and start them when needed like using an alias like

home='sudo start netctl home'

all you will have to do is type home and password.

Last edited by dag (2013-06-12 03:05:42)


--------------------------------------
alcoves wonder creates the wonder unto the ages; never lose that.

Offline

#11 2013-06-12 03:04:02

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] netctl without sudo

Aliases are what I assume the murukesh must have.  I actually do have these aliases as well, but if I get this if I run it wil the full path w/o root access:

% /usr/bin/netctl enable profile1
netctl needs root privileges

Offline

#12 2013-06-12 04:17:28

dag
Member
From: US
Registered: 2013-01-20
Posts: 216

Re: [solved] netctl without sudo

wouldnt it work if you put in visudo

user host= NOPASSWD: /usr/bin/netctl

and then in bash file use sudo (it seems to need it) but it wont ask for password, or use the full command.

Last edited by dag (2013-06-12 04:36:57)


--------------------------------------
alcoves wonder creates the wonder unto the ages; never lose that.

Offline

#13 2013-06-12 04:45:08

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] netctl without sudo

Yes it would, but the OP was being encouraged to do his own research by reading the docs.  But I guess now he has the answer.

Offline

#14 2013-06-12 04:57:47

murukesh
Member
Registered: 2013-06-11
Posts: 18

Re: [solved] netctl without sudo

dag wrote:

wouldnt it work if you put in visudo

user host= NOPASSWD: /usr/bin/netctl

and then in bash file use sudo (it seems to need it) but it wont ask for password, or use the full command.

I tried that, but that's when I get the error about preserving the environment.

[bro3886@~] $ sudo netctl start belkin
sudo: sorry, you are not allowed to preserve the environment
code 1

Note that, if I have a NOPASSWD tag for netctl, this error is thrown irrespective of whether I call sudo or netctl calls sudo.

I'm trying to see how fast I can get Arch to boot, and the biggest bottleneck is netctl connecting to my home wifi. That's why I'm trying to move netctl to post-login.

I would add it to my bashrc, but it would require me to type my password twice upon login, wouldn't it?

Offline

#15 2013-06-12 05:26:07

dag
Member
From: US
Registered: 2013-01-20
Posts: 216

Re: [solved] netctl without sudo

maybe this will help

murukesh wrote:

I would add it to my bashrc, but it would require me to type my password twice upon login, wouldn't it?

no


--------------------------------------
alcoves wonder creates the wonder unto the ages; never lose that.

Offline

#16 2013-06-12 05:33:58

murukesh
Member
Registered: 2013-06-11
Posts: 18

Re: [solved] netctl without sudo

dag wrote:

maybe this will help

murukesh wrote:

I would add it to my bashrc, but it would require me to type my password twice upon login, wouldn't it?

no

I feel extremely stupid. Just after my reply I thought of checking for aliases. There  were aliases for both netctl and sudo. Using the full paths and the NOPASSWD option, things are working fine. Boot time reduced to 15.6s from 20. Thanks, all of you!

Offline

Board footer

Powered by FluxBB