Skip to content

add umask support and use 022 in RB mode #271

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

Merged
merged 1 commit into from
May 5, 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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>plexus-archiver</artifactId>
<version>4.6.4-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
<name>Plexus Archiver Component</name>

<scm>
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ protected Logger getLogger()

private int defaultDirectoryMode = -1; // Optionally used if a value is needed

private int umask = -1;

private boolean forced = true;

private List<ArchiveFinalizer> finalizers;
Expand Down Expand Up @@ -440,14 +442,19 @@ private ArchiveEntry updateArchiveEntryAttributes( ArchiveEntry entry )
}

protected ArchiveEntry asArchiveEntry( @Nonnull final PlexusIoResource resource, final String destFileName,
final int permissions, PlexusIoResourceCollection collection )
int permissions, PlexusIoResourceCollection collection )
throws ArchiverException
{
if ( !resource.isExisting() )
{
throw new ArchiverException( resource.getName() + " not found." );
}

if ( umask > 0 )
{
permissions &= ~umask;
}

ArchiveEntry entry;
if ( resource.isFile() )
{
Expand Down Expand Up @@ -1264,6 +1271,18 @@ public String getOverrideGroupName()
return overrideGroupName;
}

@Override
public void setUmask( int umask )
{
this.umask = umask;
}

@Override
public int getUmask()
{
return umask;
}

/**
* @deprecated Use {@link #configureReproducibleBuild(FileTime)} instead.
*/
Expand All @@ -1288,6 +1307,9 @@ public void configureReproducibleBuild( FileTime lastModifiedTime )
setOverrideUserName( "root" ); // is it possible to avoid this, like "tar --numeric-owner"?
setOverrideGid( 0 );
setOverrideGroupName( "root" );

// 4. set umask to 022 to avoid environment umask value particularly on group write
setUmask( 0_022 );
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/codehaus/plexus/archiver/Archiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ ResourceIterator getResources()
*/
String getOverrideGroupName();

/**
* @since 4.7.0
*/
void setUmask( int umask );

/**
* @since 4.7.0
*/
int getUmask();

/**
* This method is obsolete and will just call {@link #configureReproducibleBuild(FileTime)}
* with the Date transformed into FileTime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ public String getOverrideGroupName()
return target.getOverrideGroupName();
}

@Override
public void setUmask( int umask )
{
target.setUmask( umask );
}

@Override
public int getUmask()
{
return target.getUmask();
}

/**
* @deprecated Use {@link #configureReproducibleBuild(FileTime)} instead.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/codehaus/plexus/archiver/diags/NoOpArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,18 @@ public String getOverrideGroupName()
return null;
}

@Override
public void setUmask( int umask )
{

}

@Override
public int getUmask()
{
return 0;
}

/**
* @deprecated Use {@link #configureReproducibleBuild(FileTime)} instead.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,18 @@ public String getOverrideGroupName()
return null;
}


@Override
public void setUmask( int umask )
{
}

@Override
public int getUmask()
{
return 0;
}

/**
* @deprecated Use {@link #configureReproducibleBuild(FileTime)} instead.
*/
Expand Down