aboutsummaryrefslogtreecommitdiff
path: root/pam
AgeCommit message (Collapse)Author
2023-09-09Re-run 'make format' with latest version of gofmtEric Biggers
2022-04-16Try to detect process being forked during PAM transactionEric Biggers
Update https://github.com/google/fscrypt/issues/350
2021-12-21Fix a few typosEric Biggers
2021-12-21pam_fscrypt: warn user if OLDAUTHTOK not given in chauthtokEric Biggers
If someone runs 'passwd USER' as root, the user is assigned a new login passphrase without their fscrypt login protector being updated. Detect this case and show a warning message using pam_info(). Fixes https://github.com/google/fscrypt/issues/273
2021-12-19pam: avoid compiler warning in copyIntoSecret()Eric Biggers
gcc 11 enabled -Wmaybe-uninitialized by default. It causes a false-positive warning in copyIntoSecret() because gcc doesn't understand that mlock() is special and doesn't read from the memory. Just initialize the memory to avoid this warning.
2020-05-10Declare instead of define variable in header file. (#224)Shuai Wang
This fixes link error with gcc 10 which defaults to -fno-common
2020-01-05pam_fscrypt: update to handle filesystem keyringEric Biggers
FS_IOC_ADD_ENCRYPTION_KEY and FS_IOC_REMOVE_ENCRYPTION_KEY require root for v1 policy keys, so update the PAM module to re-acquire root privileges while provisioning/deprovisioning policies that need this. Also, only set up the user keyring if it will actually be used.
2020-01-05Add keyring packageEric Biggers
In preparation for introducing support for the new filesystem-level keyrings, move the existing user keyring management code from security/keyring.go and crypto/crypto.go into a new package, 'keyring'. This package provides functions AddEncryptionKey, RemoveEncryptionKey, and GetEncryptionKeyStatus which delegate to either the filesystem keyring (added by a later patch) or to the user keyring. This provides a common interface to both types of keyrings, to the extent possible.
2019-09-08Fix various typos and grammatical errors (#141)ebiggers
These were found by a combination of manual review and a custom script that checks for common errors. Also removed an outdated sentence from the comment for setupBefore().
2019-07-26Update Travis to use Ubuntu 18.04 and Go 1.12 (#135)Joseph Richey
Fixes CI issues
2018-08-23Ensure setting user privileges is reversibleJoe Richey joerichey@google.com
This change makes sure after dropping then elevating privileges for a process, the euid, guid, and groups are all the same as they were originally. This significantly simplifies the privilege logic. This fixes CVE-2018-6558, which allowed an unprivleged user to gain membership in the root group (gid 0) due to the groups not being properly reset in the process.
2018-04-19Merge pull request #97 from ebiggers/privileges_fixJoseph Richey
security: drop and regain privileges in all threads
2018-03-25security: drop and regain privileges in all threadsEric Biggers
After enabling pam_fscrypt for "session" and creating a directory protected with a login protector, I was no longer able to log in as that user. The problem is that the Go runtime is creating threads after pam_fscrypt drops privileges, but pam_fscrypt is not re-acquiring privileges on those threads because the Go wrappers for setreuid(), setregid(), and setgroups() in the "sys/unix" package are using the raw syscalls which operate on the calling thread only. This violates glibc's assumption that all threads have the same uids and gids, causing it to abort() the process when a later module in the PAM stack (pam_mail in my case) tries to drop privileges using the glibc functions. Fix it by dropping and regaining privileges using the glibc functions rather than the "sys/unix" functions. This also avoids any possibility that privileges could be changed in a thread other than the "main" one for pam_fscrypt, since the Go runtime does not guarantee which OS-level thread runs what. It would be nice to also exit all Go worker threads before returning from pam_fscrypt, but the Go runtime doesn't seem to support that.
2018-03-24pam: return error when PAM info item is unsetEric Biggers
pam_fscrypt is crashing with a segfault in copyIntoSecret() when using Ctrl-C to interrupt a 'sudo' prompt. It is dereferencing a NULL pointer that is supposed point to the PAM_AUTHTOK item. The problem is that the Go code assumes pam_get_item() returns a non-success status if the item is unset, when actually it sets the data pointer to NULL and returns PAM_SUCCESS. Fix it by making pam.Handle.GetItem() return an error in that case.
2018-02-11vet: eliminate unnecessary shadowingJoseph Richey
Running "go vet -shadow ./..." finds all places where a variable might be incorrectly or unnecessarily shadowed. This fixes some of them.
2018-02-11test: all packages should have testsJoseph Richey
The tests added in this change are trivial, but they make sure that every package has a non-zero number of tests. This is important for eventually increasing test coverage.
2017-09-29security: Add check option to UserKeyringIDJoseph Richey
2017-09-01security: Change user keyring lookup algorithmJoseph Richey
Now instead of spawning a seperate thread we alternate between changing the euid and ruid to both find the keyring and link it to the process keyring. Note that we also ensure that the user keyring is linked into the root keyring whenever possible.
2017-09-01security: No more permenant privilege droppingJoseph Richey
This was creating an issue becasuse fully dropping privileges required spawning a goroutine and using rutime.DropOSThread().
2017-08-30pam: Handle holds data for calling and PAM usersJoe Richey
The functions are now changed to (Start|Stop)AsPamUser to indicate that they handle privilege modification and keyring setup.
2017-08-23pam_fscrypt: Session accounting completedJoe Richey joerichey@google.com
2017-08-23Added some documentation and improved security APIJoe Richey joerichey@google.com
2017-08-22pam_fscrypt: lock all PAM policies w/ flagJoe Richey joerichey@google.com
2017-08-22Various small nits a helper functions for PAMJoe Richey joerichey@google.com
2017-08-17cmd/fscrypt: purge command now clears cacheJoe Richey joerichey@google.com
2017-07-17Small fixes so "make lint" doesn't complain.Joe Richey joerichey@google.com
2017-07-17pam: Added missing documentation (fix "make lint")Joe Richey joerichey@google.com
2017-07-17Changes from "make format"Joe Richey joerichey@google.com
2017-07-17pam: IsUserLoginToken now uses PAM libraryJoe Richey joerichey@google.com
2017-07-17pam: Add Go wrappers around PAM functionsJoe Richey joerichey@google.com
This commit provides a Go interface to the PAM functions.
2017-07-17pam: C implementation for conversation and cleanupJoe Richey joerichey@google.com
This commit adds in a C implementation for the pam_conv we will use in login.go as well as adding three CleanupFuncs that will be used with pam_set_data(). It also adds copyInfoSecret() which should be paired with freeSecret().
2017-07-17pam: Add PAM Items and FlagsJoe Richey joerichey@google.com
Code pulled from github.com/msteinert/pam
2017-06-28Finalize import paths and documentationv0.1.00.1.0Joe Richey joerichey@google.com
This commit changes all the internal import paths from `fscrypt/foo` to `github.com/google/fscrypt/foo` so that it can be built once we release externaly. The documentation in README.md is updated accordingly. Also, the README has a note noting that we do not make any guarantees about project stability before 1.0 (when it ships with Ubuntu). Change-Id: I6ba86e442c74057c8a06ba32a42e17f94833e280
2017-06-28Change error handling to new packageJoe Richey joerichey@google.com
This commit changes the error handing for the crypto, filesystem, metadata, pam, and util packages to use the error handling library github.com/pkg/errors. This means elimination of the FSError type, an increased use of wrapping errors (as opposed to logging), switching on the Cause() of an error (as opposed to its value), and improving our integration tests involving TEST_FILESYSTEM_ROOT. This commit also fixes a few bugs with the keyring code to ensure that our {Find|Remove|Insert}PolicyKey functions are always operating on the same keyring. The check for filesystem support has been moved from the filesystem package to the metadata package. Finally, the API for the filesystem package has been slightly modified: * filesystem.AllFilesystems() now returns all the filesystems in sorted order * certain path methods are now public O_SYNC is also removed for writing the metadata. We don't get that much from syncing the metadata, as the actual file data could also be corrupted by and IO error. The sync operation is also occasionally very slow (~3 seconds) and can be unfriendly to battery life. Change-Id: I392c2655141714b16dfdbc84ac09780072be2cf0
2017-06-15pam: checking a user's login passphraseJoe Richey joerichey@google.com
This commit adds in the fscrypt/pam package. This package will hold all functionality related to Linux Pluggable Authentication Modules (PAM). Right now this package uses cgo to mock a PAM conversation, allowing the function to check if a provided passphrase actually belongs to a user. Due to the nature of cgo callbacks, global state of the key to check is necessary for this function. This commit also addresses some issues about building the cgo components. Now, only the minimal linking flags are included in the go files. Additional linker flags may now be necessary to build a static binary of fscrypt. This is addressed in the Makefile and README. Finally, this commit fixes a bug where the tests would not run correctly due to shared global state on the testing filesystem. Fixed, by having all the tests run sequentially. Change-Id: Ia43636801da984b505d2f43dd14127b7cfbf2c48