Add (disabled) generation of authorized_keys
[mirror/userdir-ldap.git] / ud-generate
index 30a1111..ec618d8 100755 (executable)
@@ -702,7 +702,7 @@ def GenBSMTP(l,File,HomePrefix):
   Done(File,F,None);
 
 # Generate the ssh known hosts file
-def GenSSHKnown(l,File):
+def GenSSHKnown(l,File,mode=None):
   F = None;
   try:
    OldMask = os.umask(0022);
@@ -723,6 +723,8 @@ def GenSSHKnown(l,File):
       if SHost != None: HostNames += [Host[0:SHost]]
 
       IPAdressesT = None
+      IPAdresses = []
+      # get IP adresses back as "proto adress" to distinguish between v4 and v6
       try:
          IPAdressesT = set([ (a[0],a[4][0]) for a in socket.getaddrinfo(Host, None)])
       except:
@@ -730,8 +732,13 @@ def GenSSHKnown(l,File):
       for addr in IPAdressesT:
          if addr[0] == socket.AF_INET: IPAdresses += [addr[1], "::ffff:"+addr[1]]
         else: IPAdresses += [addr[1]]
+
       for I in x[1]["sshRSAHostKey"]:
-         Line = "%s,%s %s" %(",".join(HostNames + IPAdresses), I);
+         if mode and mode == 'authorized_keys':
+            #Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="%s" %s' % (Host, ",".join(HNames + IPAdresses), I)
+            Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding %s' % (Host,I)
+         else:
+            Line = "%s %s" %(",".join(HostNames + IPAdresses), I);
          Line = Sanitize(Line) + "\n";
          F.write(Line);
   # Oops, something unspeakable happened.
@@ -820,6 +827,7 @@ GenMarkers(l,GlobalDir+"markers");
 GenPrivate(l,GlobalDir+"debian-private");
 GenDisabledAccounts(l,GlobalDir+"disabled-accounts");
 GenSSHKnown(l,GlobalDir+"ssh_known_hosts");
+#GenSSHKnown(l,GlobalDir+"authorized_keys", 'authorized_keys');
 GenHosts(l,GlobalDir+"debianhosts");
 GenMailDisable(l,GlobalDir+"mail-disable");
 GenMailBool(l,GlobalDir+"mail-greylist","mailGreylisting");