]> andersk Git - moira.git/blobdiff - update/send_file.c
Command line printer manipulation client, and build goo.
[moira.git] / update / send_file.c
index 2ebb245e1e97c99ebc14ff855b8c9192b981637d..49127f41b2f02b5c58013f4245e304440d73fa0a 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+#ifdef HAVE_KRB4
 #include <des.h>
+#endif
 #include <update.h>
 
 RCSID("$Header$");
 
+#ifdef HAVE_KRB4
 extern des_cblock session;
+#endif
 
 /*
  * syntax:
@@ -47,8 +51,10 @@ int mr_send_file(int conn, char *pathname, char *target_path, int encrypt)
   char data[UPDATE_BUFSIZ], enc[UPDATE_BUFSIZ];
   long response;
   struct stat statb;
+#ifdef HAVE_KRB4
   des_key_schedule sched;
   des_cblock ivec;
+#endif
 
   /* send file over */
   fd = open(pathname, O_RDONLY, 0);
@@ -105,8 +111,15 @@ int mr_send_file(int conn, char *pathname, char *target_path, int encrypt)
 
   if (encrypt)
     {
+#ifdef HAVE_KRB4
       des_key_sched(session, sched);
       memmove(ivec, session, sizeof(ivec));
+#else
+      /* The session key only gets stored if auth happens in krb4 to
+         begin with. If you don't have krb4, you can't possibly be
+         coming up with a valid session key. */
+      return MR_NO_KRB4;
+#endif
     }
 
   while (n_to_send > 0)
@@ -120,14 +133,16 @@ int mr_send_file(int conn, char *pathname, char *target_path, int encrypt)
        }
       if (encrypt)
        {
+#ifdef HAVE_KRB4
          memset(data + n, 0, sizeof(data) -n);
-         des_pcbc_encrypt(data, enc, n, sched, ivec, 0);
+         des_pcbc_encrypt(data, enc, (n + 7) & ~7, sched, ivec, 0);
          /* save vector to continue chaining */
          for (i = 0; i < 8; i++)
            ivec[i] = data[n - 8 + i] ^ enc[n - 8 + i];
          /* round up to multiple of 8 */
          n = (n + 7) & ~7;
          code = send_string(conn, enc, n);
+#endif
        }
       else
        code = send_string(conn, data, n);
This page took 0.044544 seconds and 4 git commands to generate.