summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java')
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java66
1 files changed, 64 insertions, 2 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java b/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java
index 864e954..d06bff8 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
@@ -44,12 +45,34 @@ public class CreateLdapConfig extends AbstractTask
@Expose
private String home = null;
@Expose
+ private String homeattr = null;
+ @Expose
private String fingerprint;
@Expose
private String certificate;
@Expose
private boolean plainldap = false;
+ // Share mode stuff
+ @Expose
+ private int shareRemapMode;
+ @Expose
+ private int shareRemapCreate;
+ @Expose
+ private String shareHomeDrive;
+ @Expose
+ private int shareDocuments;
+ @Expose
+ private int shareDownloads;
+ @Expose
+ private int shareDesktop;
+ @Expose
+ private int shareMedia;
+ @Expose
+ private int shareOther;
+ @Expose
+ private List<Share> shares;
+
private Output status = new Output();
@Override
@@ -145,6 +168,7 @@ public class CreateLdapConfig extends AbstractTask
+ "bindpw=%s\n"
+ "base=%s\n"
+ "home=%s\n"
+ + "homeattr=%s\n"
+ "port=%s\n"
+ "fingerprint=%s\n"
+ "cabundle=%s\n"
@@ -159,6 +183,7 @@ public class CreateLdapConfig extends AbstractTask
this.bindpw,
this.searchbase,
this.home,
+ this.homeattr,
this.adport,
this.fingerprint,
caPath,
@@ -176,13 +201,40 @@ public class CreateLdapConfig extends AbstractTask
sssdConf.replace( "%URI%", uri );
sssdConf.replace( "%SEARCHBASE%", this.searchbase );
sssdConf.replace( "%CACERT%", cacertPath );
- String fileName = "/opt/ldadp/configs/" + this.moduleid + ".cfg";
+ // Sharemode config
+ String shareConf = String.format(
+ "SHARE_REMAP_MODE=%d\n"
+ + "SHARE_CREATE_MISSING_REMAP=%d\n"
+ + "SHARE_HOME_DRIVE=%s\n"
+ + "SHARE_DOCUMENTS=%d\n"
+ + "SHARE_DOWNLOADS=%d\n"
+ + "SHARE_DESKTOP=%d\n"
+ + "SHARE_MEDIA=%d\n"
+ + "SHARE_OTHER=%d\n",
+ this.shareRemapMode,
+ this.shareRemapCreate,
+ this.shareHomeDrive,
+ this.shareDocuments,
+ this.shareDownloads,
+ this.shareDesktop,
+ this.shareMedia,
+ this.shareOther
+ );
+ if ( this.shares != null && !this.shares.isEmpty() ) {
+ int i = 0;
+ for ( Share s : this.shares ) {
+ shareConf += String.format( "SHARE_%d='%s\t%s\t%s\t%s\t%s'\n",
+ ++i, s.share, s.letter, s.shortcut, s.user, s.pass );
+ }
+ }
+ // Build tar/config
+ String ldadpConfigPath = "/opt/ldadp/configs/" + this.moduleid + ".cfg";
try {
Files.deleteIfExists( Paths.get( this.filename ) );
} catch ( IOException e1 ) {
}
try {
- FileUtils.writeStringToFile( new File( fileName ), ldadpConf, StandardCharsets.UTF_8 );
+ FileUtils.writeStringToFile( new File( ldadpConfigPath ), ldadpConf, StandardCharsets.UTF_8 );
if ( 0 != Exec.sync( 10,
"/usr/bin/sudo",
"-n",
@@ -226,6 +278,7 @@ public class CreateLdapConfig extends AbstractTask
}
boolean ret = Archive.tarCreateFileFromString( outArchive, "/etc/ldap.conf", ldapConf.toString(), 0644 )
&& Archive.tarCreateFileFromString( outArchive, "/etc/sssd/sssd.conf", sssdConf.toString(), 0600 )
+ && Archive.tarCreateFileFromString( outArchive, "/opt/openslx/inc/shares", shareConf, 0644 )
&& Archive.tarCreateSymlink( outArchive, "/etc/ldap.conf", "/etc/ldap/ldap.conf" )
&& Archive.tarCreateSymlink( outArchive, "/etc/ldap.conf", "/etc/openldap/ldap.conf" )
&& Archive.tarCreateSymlink( outArchive, "../sssd.service", "/etc/systemd/system/basic.target.wants/sssd.service" );
@@ -250,4 +303,13 @@ public class CreateLdapConfig extends AbstractTask
protected String error = null;
}
+ private static class Share
+ {
+ protected String share;
+ protected String letter;
+ protected String shortcut;
+ protected String user;
+ protected String pass;
+ }
+
}