Skip to content

Commit

Permalink
Merge pull request #429 from breskeby/setgid-support
Browse files Browse the repository at this point in the history
Add explicit setgid support to Rpm and Deb tasks
  • Loading branch information
rpalcolea authored Sep 25, 2023
2 parents 91a4faf + 5b21d51 commit 3149924
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ class DebCopyAction extends AbstractPackagingCopyAction<Deb> {
Integer uid = (Integer) lookup(specToLookAt, 'uid') ?: task.uid ?: 0
String group = lookup(specToLookAt, 'permissionGroup') ?: task.permissionGroup
Integer gid = (Integer) lookup(specToLookAt, 'gid') ?: task.gid ?: 0
String setgid = lookup(specToLookAt, 'setgid') ?: task.setgid

int fileMode = dirDetails.mode

if (setgid) {
fileMode = fileMode | 02000
}
debFileVisitorStrategy.addDirectory(dirDetails, user, uid, group, gid, fileMode)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class CopySpecEnhancement {
user(spec, userArg)
}

static void setgid(CopySpec spec, boolean setgid) {
appendFieldToCopySpec(spec, 'setgid', setgid)
}

static void setSetgid(CopySpec spec, boolean setgid) {
setgid(spec, setgid)
}

static void permissionGroup(CopySpec spec, String permissionGroup) {
appendFieldToCopySpec(spec, 'permissionGroup', permissionGroup)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class SystemPackagingExtension {
File signingKeyRingFile
String user
String permissionGroup // Group is used by Gradle on tasks.
Boolean setgid

/**
* In Debian, this is the Section and has to be provided. Valid values are: admin, cli-mono, comm, database, debug,
* devel, doc, editors, education, electronics, embedded, fonts, games, gnome, gnu-r, gnustep, graphics, hamradio,
Expand Down Expand Up @@ -180,6 +182,12 @@ class SystemPackagingExtension {
return permissionGroup
}

@Input
@Optional
Boolean getSetgid() {
return setgid
}

@Input
@Optional
String getPackageGroup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ abstract class SystemPackagingTask extends OsPackageAbstractArchiveTask {
mapping.map('maintainer', { parentExten?.getMaintainer() ?: getPackager() })
mapping.map('uploaders', { parentExten?.getUploaders() ?: getPackager() })
mapping.map('permissionGroup', { parentExten?.getPermissionGroup() ?: '' })
mapping.map('setgid', { parentExten?.getSetgid() ?: false })
mapping.map('packageGroup', { parentExten?.getPackageGroup() })
mapping.map('buildHost', { parentExten?.getBuildHost() ?: HOST_NAME })
mapping.map('summary', { parentExten?.getSummary() ?: getPackageName() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ class RpmCopyAction extends AbstractPackagingCopyAction<Rpm> {
Directive directive = (Directive) lookup(specToLookAt, 'fileType') ?: task.fileType
String user = lookup(specToLookAt, 'user') ?: task.user
String group = lookup(specToLookAt, 'permissionGroup') ?: task.permissionGroup

String setgid = lookup(specToLookAt, 'setgid') ?: task.setgid
if (setgid) {
dirMode = dirMode | 02000
}
rpmFileVisitorStrategy.addDirectory(dirDetails, dirMode, directive, user, group, addParentsDir)
}
}
Expand Down

0 comments on commit 3149924

Please sign in to comment.