You are not logged in.

#1 2017-06-12 22:51:27

phoenix310
Member
Registered: 2017-06-10
Posts: 5

Login Script[SOLVED]

Hello all! I'm using MATE desktop with LightDM and the GTK greeter. I have a script that mounts my CIFS shares and I would like to have it run when I logon. I've already set it to not require a password using visudo. In Debian, I had to place a line in the .profile file with the absolute path to the script and it worked perfectly. In Fedora, I had to do the same, but place the line in the .bash_profile. I've attempted placing the file in the .bash_profile and it does not run at all (as a matter of face, anything I place in that file doesn't get executed at login. I've also tried exporting my personal bin and git folder to the $PATH and it doesn't work either). I've tried adding the script to the startup applications as well but still no dice. Any help would be greatly appreciated smile

This is my .bash_profile

 
#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
 
#export bin and git
export PATH=$PATH:~/bin:~/git

# network shares
sudo /home/phoenix/bin/./shares.sh

Last edited by phoenix310 (2017-06-17 17:11:37)

Offline

#2 2017-06-13 09:10:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,294

Re: Login Script[SOLVED]

https://wiki.archlinux.org/index.php/Pam_mount

This btw. also spares you the NOPASSWD sudo

bash_profile is sourced whenever you open a bash login shell, not whenever you login "somehow".
/etc/profile is sourced by about every shell, what is certainly not what you want here (at best causing a idempotent delay on every shell start)

Offline

#3 2017-06-13 13:59:40

phoenix310
Member
Registered: 2017-06-10
Posts: 5

Re: Login Script[SOLVED]

Thanks for the reply Seth! I'll try it when I get home from work this evening and see if how it works. The file looks a bit complicated but I think I should be able to figure out how to get my script running with it. I'm wondering how this would fare with multiple users as well. Guess I'll find out when I test drive it wink

Offline

#4 2017-06-14 21:19:44

phoenix310
Member
Registered: 2017-06-10
Posts: 5

Re: Login Script[SOLVED]

I did attempt using the pam_mount. I couldn't get it to do what I wanted but it might've been me just not understanding how to do things with it. I'll play a little more with it to see if I can get it to work how I need it too. Thanks for the tip!!

Offline

#5 2017-06-15 06:27:36

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,294

Re: Login Script[SOLVED]

As last resort you can make use of the session-setup-script and session-cleanup-script keys in a "[SeatDefaults]" section in some /etc/lightdm/lightdm.conf.d/mount_stuff.conf - the setup script should probably check the UID or run a script in the $HOME of the user.

Offline

#6 2017-06-17 17:07:31

phoenix310
Member
Registered: 2017-06-10
Posts: 5

Re: Login Script[SOLVED]

I tinkered with it a bit and got it working. pam_mount is waaaaaaaay better than the way I was doing things before. Thanks for the guidance!!!!

EDIT: For anyone curious as to how I set it up, here are my config files

EDIT 2: I found that I was having issues with pam_mount accessing sudo as well. I kept getting errors about root not being able to unmount the network shares. It turns out that you need to not add the pam_mount.so entries into the system-auth file, but to the file for whatever Display manager (if one is being used) that is enabled.

This link helped me with that:
https://bbs.archlinux.org/viewtopic.php?id=179666

/etc/security/pam_mount.conf.xml

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<!--
        See pam_mount.conf(5) for a description.
-->

<pam_mount>

                <!-- debug should come before everything else,
                since this file is still processed in a single pass
                from top-to-bottom -->

<debug enable="0" />

                <!-- Volume definitions -->


                <!-- pam_mount parameters: General tunables -->

<!--
<luserconf name=".pam_mount.conf.xml" />
-->

<!-- Note that commenting out mntoptions will give you the defaults.
     You will need to explicitly initialize it with the empty string
     to reset the defaults to nothing. -->
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
<!--
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
-->
<mntoptions require="nosuid,nodev" />

<!-- requires ofl from hxtools to be present -->
<logout wait="0" hup="no" term="no" kill="no" />

<volume user="%(USER)" fstype="auto" path="~/" mountpoint="~/" options="fsck,noatime" />

                <!-- pam_mount parameters: Volume-related -->

                 <volume fstype="cifs" path="//path/to/network/share" mountpoint="/mount/point" uid="%(USERID)" />
                 
<mkmountpoint enable="1" remove="true" />


</pam_mount>

and the /etc/pam.d/lightdm (my DM)

#%PAM-1.0
auth        optional    pam_mount.so
auth        include     system-login
-auth       optional    pam_gnome_keyring.so
account     include     system-login
password    include     system-login
password    optional    pam_mount.so
session     include     system-login
session     optional    pam_mount.so
-session    optional    pam_gnome_keyring.so auto_start

Still going to tinker around with it to get it tailored to my liking but I got the general gist of it!! Hope this helps anyone! big_smile

Last edited by phoenix310 (2017-08-16 23:28:57)

Offline

Board footer

Powered by FluxBB