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

Add explicit setgid support to Rpm and Deb tasks #429

Merged
merged 3 commits into from
Sep 25, 2023
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
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
Loading