unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: znavko--- via <help-guix@gnu.org>
To: "help-guix" <help-guix@gnu.org>
Subject: Allow my usual user reconnect to wifi without root pass and also replace wpa config
Date: Fri, 01 Jan 2021 19:07:16 +0000	[thread overview]
Message-ID: <97dc5a852f972d7191ece0f64c9ec2fc@disroot.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

Hello! Happy New Year, Guix Help!

I'd like to make my OS a bit comfortable for usual user.

I use only wpa_supplicant + dhclient without any utility that gives control over wifi to usual users.
And I want to give such a control by my own hands and your advice.

Wi-fi connection sometimes is loosing, and the way to reconnect is to restart hurd services.
I do it by root beautifully. I need to allow usual user to do this too.

With that task I also have two providers: wired ISP and Mobile ISP -
And I have such a script for choosing between them.
Attachment: wpa

So this script fulfill things of reconnection and changing wpa_supplicant.conf
very easy for root.
I want to allow to usual user just to run:

$ /wpa isp

and my script reconnect to wifi again.

I tried to give root privileges for user 'bob' to run script /wpa with this line in /etc/sudoers:
# cat /etc/sudoers
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
user ALL=(bob) NOPASSWD: /wpa
#groups bob
bob : users wheel video audio netdev
But I still have these error messages:

$ sudo -u bob /wpa isp
Connecting to ISP provider
cp: cannot create regular file '/etc/wpa_supplicant/wpa_supplicant.conf': Permission denied
error: connect: /run/user/1000/shepherd/socket: No such file or directory
error: connect: /run/user/1000/shepherd/socket: No such file or directory
^X^C
$
Please, what to do here?

[-- Attachment #2: wpa --]
[-- Type: application/octet-stream, Size: 807 bytes --]

#!/bin/sh

usage() {
  echo "Usage: $0 provider"
  echo "where provider is one of using providers"
  exit 1
}

if [ $# -eq 0 ]
  then
    echo "No arguments supplied"
    usage
fi

case "$1" in
  "isp")
    echo "Connecting to ISP provider"
    cp /etc/wpa_supplicant/wpa_isp.conf /etc/wpa_supplicant/wpa_supplicant.conf
    herd stop networking
    herd stop wpa-supplicant
    sleep 8
    herd start wpa-supplicant
    sleep 8
    herd start networking
    ;;
  "bee")
    echo "mob"
    echo "Connecting to Mobile provider"
    cp /etc/wpa_supplicant/wpa_mob.conf /etc/wpa_supplicant/wpa_supplicant.conf
    herd stop networking
    herd stop wpa-supplicant
    sleep 8
    herd start wpa-supplicant
    sleep 8
    herd start networking
    ;;
  *)
    echo "Provider is not of cases"
    exit 2;
esac


             reply	other threads:[~2021-01-01 19:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-01 19:07 znavko--- via [this message]
2021-01-02  0:01 ` Allow my usual user reconnect to wifi without root pass and also replace wpa config znavko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97dc5a852f972d7191ece0f64c9ec2fc@disroot.org \
    --to=help-guix@gnu.org \
    --cc=znavko@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).