LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-31-2024, 11:38 AM   #1
PreguntoYo
Member
 
Registered: Jan 2012
Distribution: openSUSE, Gentoo, Slackware
Posts: 73

Rep: Reputation: 15
Question How do I set file permissions using PAM?


Hello:

I'm using Slackware 15.0 stable, and I'm trying to set my file's permissions using PAM.

I want something like this:

foo.file: rw-rw----

Because all my files belong to my own personal group.

I've edited /etc/pam.d/system.auth adding this at the end:

Code:
session [default=1 success=ignore] pam_succeed_if.so quiet uid eq 1000
session optional pam_umask.so umask=0007
And... I didn't work. The idea here was that all my new files would be created rw-rw----, directories drw-rw---- and I'd set something more specific if needed be.

Can anyone help, please?.
 
Old 03-31-2024, 12:58 PM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 786

Rep: Reputation: 250Reputation: 250Reputation: 250
Maybe try 0006? I don't use PAM for this, but mine is 0066 for rw-------.
 
Old 03-31-2024, 01:42 PM   #3
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 978

Rep: Reputation: 667Reputation: 667Reputation: 667Reputation: 667Reputation: 667Reputation: 667
Why try to set the umask with pam? Why not simply set the umask with a login script below /etc/profile.d or in your home directory? Another option would be to edit the umask setting in /etc/profile or whatever file your shell is using.

regards Henrik
 
Old 03-31-2024, 07:55 PM   #4
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 770

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Perhaps try a test without the 'pam_succeed_if' line. Usually "succeed" means if you pass the test, your authentication is deemed as "succeeded" and pam exits the stack, without running further lines. You could also try removing the "quiet" and adding "debug" temporarily to get a little more verbose logging in /var/log/secure. Might find something helpful there as to how pam is handling things.

However, the default umask gets set in the /etc/profile script and would be easier to change there, no?

Last edited by 0XBF; 03-31-2024 at 07:57 PM. Reason: grammar
 
Old 04-01-2024, 12:57 PM   #5
PreguntoYo
Member
 
Registered: Jan 2012
Distribution: openSUSE, Gentoo, Slackware
Posts: 73

Original Poster
Rep: Reputation: 15
Hello:

I have other Linux distros installed in different disks in another system. Sometimes I take things that I like from them and try them in Slackware. If I like them, I'll keep them.

This experiment came from openSUSE:

https://en.opensuse.org/SDB:Set_UMASK

I know that there are other ways to change my umask: /etc/profile, files /etc/profile.d, .bashrc, etc.

I wanted to get more familiar with PAM, also I wanted to put it to practical use (now that it is included in Slackware).

I've had a first fast read of some of PAM's man pages, but some man pages are written more clearly than others.

I figured /etc/pam.d/system.auth would be the correct file to edit, I'm aware that this file could be overwritten in an update.

Anyway, I'm still open to suggestions.


Greetings to all of you.
 
1 members found this post helpful.
Old 04-01-2024, 03:00 PM   #6
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 770

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Did you disable setting the umask via /etc/profile then? (And any other login scripts).

I would imagine that any changes made to the umask at the pam stage would be overrode later once bash starts up and sources its profile scripts. That article you linked may call profile scripts obsolete, but they are still used and sourced on Slackware.

Adding 'debug' to those lines would show in the logs what pam is doing. My guess would be bash is still changing umask back to system default via /etc/profile though.
 
2 members found this post helpful.
Old 04-01-2024, 05:11 PM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
Quote:
Originally Posted by 0XBF View Post
Perhaps try a test without the 'pam_succeed_if' line. Usually "succeed" means if you pass the test, your authentication is deemed as "succeeded" and pam exits the stack, without running further lines.
I think you're thinking of "sufficient" there.

Anyway, the pam lines look reasonable, so I share your guess that it's being set and subsequently overwritten by the profile or Xsession files.
 
2 members found this post helpful.
Old 04-01-2024, 06:53 PM   #8
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,674

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
PAM is a Pluggable Authentication Module system. Pam is not the place where you should decide to make file system ownership or permission changes, that is not what it is for.

You could script this and call it on boot from almost any flavor of CRON system, or form the logon start scripts. That would make better sense. (Depending upon WHY you want this, of course.)

Last edited by wpeckham; 04-01-2024 at 06:54 PM.
 
Old 04-02-2024, 06:50 AM   #9
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 770

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Quote:
Originally Posted by GazL View Post
I think you're thinking of "sufficient" there.

Anyway, the pam lines look reasonable, so I share your guess that it's being set and subsequently overwritten by the profile or Xsession files.
Indeed I was. A while back I had a pam_succeed_if module paired with "sufficient" on another machine where I was trying to run a root account outside of elogind. In OP's case I don't think that is the problem because of the "[default=1 success=ignore]" condition. A debug log should show pam setting umask, which would then point us to look elsewhere like profile scripts.
 
  


Reply

Tags
pam, pam.d



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
/etc/pam.d/system-auth-ac vs. /etc/pam.d/password-auth-ac vs. /etc/pam.d/sshd christr Red Hat 2 08-01-2014 07:08 PM
Help with PAM and PAM modules bourne Linux - Security 6 11-02-2008 11:48 PM
PAM module:passwd:- how many character validate by pam library amit_pansuria Linux - General 3 10-21-2008 01:19 AM
vsftpd + pam + virtual users - Pam cannot load database file. mdkelly069 Linux - Networking 3 09-22-2004 11:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:37 PM.

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