~ubuntu-branches/ubuntu/oneiric/dma/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/37-gnu-hurd.patch

  • Committer: Bazaar Package Importer
  • Author(s): Tarun Kumar Mall
  • Date: 2011-03-09 17:46:56 UTC
  • mfrom: (7.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110309174656-7s0buxoxvsos8ua1
Tags: 0.0.2010.06.17-10ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Patch 38_fix_ftbfs_binutils-gold.patch imported from previous
    ubuntu version.
  - Patch 38_fix_ftbfs_binutils-gold.patch renamed to
    42_fix_ftbfs_binutils-gold.patch
  - Patch 43_fix_ftbfs_Werror.patch added to fix 
    crypto.c:92:7: error: assignment discards 'const' qualifier 
    from pointer target type [-Werror] "Closes: #622052"

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Description: Further fixes to the build on the GNU Hurd
2
2
 - include <sys/file.h> for LOCK_EX
3
 
 - define MAXHOSTNAMELEN if absent
4
 
Forwarded: no
 
3
 - look harder for the maximum length of a hostname
 
4
Forwarded: http://gitorious.org/dma/dma/merge_requests/5
5
5
Author: Peter Pentchev <roam@ringlet.net>
6
 
Last-Update: 2010-10-16
 
6
Last-Update: 2011-02-23
7
7
 
8
8
--- a/spool.c
9
9
+++ b/spool.c
25
25
 #include <errno.h>
26
26
 #include <fcntl.h>
27
27
 #include <netdb.h>
28
 
@@ -43,6 +44,14 @@
29
 
 
30
 
 #include "dma.h"
31
 
 
32
 
+/**
33
 
+ * A quick'n'dirty hack to get dma to build on the GNU Hurd.
34
 
+ * A real fix would dynamically allocate the hostname array.
35
 
+ */
36
 
+#ifndef MAXHOSTNAMELEN
37
 
+#define MAXHOSTNAMELEN 1024
38
 
+#endif
39
 
+
 
28
@@ -46,7 +47,8 @@
40
29
 const char *
41
30
 hostname(void)
42
31
 {
 
32
-       static char name[MAXHOSTNAMELEN+1];
 
33
+       static size_t namelen = 0;
 
34
+       static char *name = NULL;
 
35
        static int initialized = 0;
 
36
        FILE *fp;
 
37
        char *res;
 
38
@@ -55,15 +57,49 @@
 
39
        if (initialized)
 
40
                return (name);
 
41
 
 
42
+#ifdef _SC_HOST_NAME_MAX
 
43
+       if (namelen == 0)
 
44
+       {
 
45
+               long scval;
 
46
+
 
47
+               scval = sysconf(_SC_HOST_NAME_MAX);
 
48
+               if (scval > 0)
 
49
+               {
 
50
+                       namelen = (size_t)scval;
 
51
+                       if ((long)namelen != scval)
 
52
+                               namelen = 0;
 
53
+                       else
 
54
+                               namelen++;
 
55
+               }
 
56
+       }
 
57
+#endif
 
58
+       if (namelen == 0)
 
59
+#ifdef HOST_NAME_MAX
 
60
+               namelen = HOST_NAME_MAX + 1;
 
61
+#else
 
62
+#ifdef MAXHOSTNAMELEN
 
63
+               namelen = MAXHOSTNAMELEN + 1;
 
64
+#else
 
65
+               namelen = 1024 + 1;
 
66
+#endif
 
67
+#endif
 
68
+
 
69
+       if (name == NULL)
 
70
+       {
 
71
+               name = malloc(namelen);
 
72
+               if (name == NULL)
 
73
+                       return ("(unknown hostname)");
 
74
+       }
 
75
+
 
76
        if (config.mailname != NULL && config.mailname[0] != '\0') {
 
77
-               snprintf(name, sizeof(name), "%s", config.mailname);
 
78
+               snprintf(name, namelen, "%s", config.mailname);
 
79
                initialized = 1;
 
80
                return (name);
 
81
        }
 
82
        if (config.mailnamefile != NULL && config.mailnamefile[0] != '\0') {
 
83
                fp = fopen(config.mailnamefile, "r");
 
84
                if (fp != NULL) {
 
85
-                       res = fgets(name, sizeof(name), fp);
 
86
+                       res = fgets(name, namelen, fp);
 
87
                        fclose(fp);
 
88
                        if (res != NULL) {
 
89
                                len = strlen(name);
 
90
@@ -78,7 +114,7 @@
 
91
                        }
 
92
                }
 
93
        }
 
94
-       if (gethostname(name, sizeof(name)) != 0)
 
95
+       if (gethostname(name, namelen) != 0)
 
96
                strcpy(name, "(unknown hostname)");
 
97
        initialized = 1;
 
98
        return name;