cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] Changes to ccvs/src/server.c [signed-commits]


From: Derek Robert Price
Subject: [Cvs-cvs] Changes to ccvs/src/server.c [signed-commits]
Date: Fri, 14 Oct 2005 21:39:38 -0400

Index: ccvs/src/server.c
diff -u ccvs/src/server.c:1.450.2.2 ccvs/src/server.c:1.450.2.3
--- ccvs/src/server.c:1.450.2.2 Fri Oct 14 16:45:51 2005
+++ ccvs/src/server.c   Sat Oct 15 01:39:25 2005
@@ -2029,6 +2029,71 @@
        non-kopt case alone.  */
     if (kopt != NULL)
        serve_is_modified (arg);
+
+    /* If an OpenPGP signature was sent for this file, write it to a temp
+     * file.
+     */
+    if (sig_buf)
+    {
+       char *sigfile_name, *sig_data;
+       int fd, rc;
+       size_t got;
+
+       /* Write the file.  */
+       sigfile_name = Xasprintf ("%s%s%s", BAKPREFIX, arg, ".sig");
+       fd = CVS_OPEN (sigfile_name, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+       if (fd < 0)
+       {
+           int save_errno = errno;
+           if (alloc_pending (40 + strlen (arg)))
+               sprintf (pending_error_text, "E cannot open `%s'",
+                        sigfile_name);
+           pending_error = save_errno;
+           return;
+       }
+
+       while (!buf_empty_p (sig_buf))
+       {
+           if ((rc = buf_read_data (sig_buf, buf_length (sig_buf), &sig_data,
+                                    &got)))
+           {
+               /* Since !buf_empty_p confirmed that the buffer was not empty,
+                * it should be impossible to get EOF here.
+                */
+               assert (rc != -1);
+
+               if (rc == -2)
+                   pending_error = ENOMEM;
+               else if (alloc_pending (80))
+                   sprintf (pending_error_text,
+                            "E error reading signature buffer.");
+               pending_error = rc;
+               return;
+           }
+
+           if (write (fd, sig_data, got) < 0)
+           {
+               int save_errno = errno;
+               if (alloc_pending (80 + strlen (sigfile_name)))
+                   sprintf (pending_error_text,
+                            "E error writing temporary signature file `%s'.",
+                            sigfile_name);
+               pending_error = save_errno;
+               return;
+            }
+       }
+
+       if (close (fd) < 0 
+           && alloc_pending_warning (80 + strlen (sigfile_name)))
+           sprintf (pending_warning_text,
+                    "E error closing temporary signature file `%s'.",
+                    sigfile_name);
+       free (sigfile_name);
+
+       /* We're done with the SIG_BUF.  */
+       buf_free (sig_buf);
+       sig_buf = NULL;
+    }
 }
 
 
@@ -2038,8 +2103,15 @@
 {
     int status;
 
-    if (!sig_buf)
+    if (sig_buf)
+    {
+       if (alloc_pending (80))
+           sprintf (pending_error_text,
+"E Multiple Signature requests received for a single file.");
+    }
+    else
        sig_buf = buf_nonio_initialize (NULL);
+
     status = read_signature (buf_from_net, sig_buf);
     if (status)
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]