Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuid and setgid with given user for git pull #760

Merged
merged 3 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aura/aura.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ common libexec
, scheduler >=1.1 && <2.1
, transformers ^>=0.5
, typed-process ^>=0.2
, unix ^>=2.7.2.2

library
import: commons, libexec
Expand Down
8 changes: 6 additions & 2 deletions aura/lib/Aura/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import qualified RIO.Set as S
import qualified RIO.Text as T
import RIO.Time
import System.Process.Typed
import System.Posix.User

---

Expand Down Expand Up @@ -193,8 +194,11 @@ pullRepo :: User -> RIO Env (Either Failure ())
pullRepo usr = do
logDebug "git: Clearing worktree. "
void . runProcess . setStderr closed . setStdout closed $ proc "git" ["reset", "--hard", "HEAD"]
logDebug "git: Pulling repo."
ec <- runProcess . setStderr closed . setStdout closed $ proc "git" ["pull"]
logDebug $ "git: Pulling repo as " <> display (user usr)
ue <- liftIO . getUserEntryForName . T.unpack . user $ usr
let uid = userID ue
let gid = userGroupID ue
ec <- runProcess . setChildUser uid . setChildGroup gid . setStderr closed . setStdout closed $ proc "git" ["pull"]
case ec of
ExitFailure _ -> pure . Left . Failure $ FailMsg buildFail_12
ExitSuccess -> liftIO (chown usr "." ["-R"]) $> Right ()
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-19.1
resolver: lts-19.4

ghc-options:
$everything: -split-sections -haddock
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ packages:
hackage: text-2.0
snapshots:
- completed:
size: 617355
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/1.yaml
sha256: cbd5e8593869445794924668479b5bd9f1738d075898623dceacc13b2576b6e3
original: lts-19.1
size: 618683
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/4.yaml
sha256: d4ee004c46ba878d2f304f5d748d493057be579192a8d148527f3ba55c9df57f
original: lts-19.4