help-hurd
[Top][All Lists]
Advanced

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

ssmtp on the Hurd


From: Christopher Bodenstein
Subject: ssmtp on the Hurd
Date: Mon, 24 Jan 2005 14:18:31 +0100
User-agent: Mutt/1.5.6+20040907i

Hello folks,

Here is a patch to build ssmtp (a simple SMTP forwarder) on the Hurd. 

Any comments and suggestions would bemost welcome. :) 

FWIW, I'm using it without any problems since Saturday (but it's a
rather light usage though).

Best regards,

Chris

-- 
 ,''`.  Christopher `Physicman' Bodenstein <cb@physicman.net>
 : :' :  Physicman.Net     :   http://www.physicman.net/ 
 `. `'   Debian GNU/Hurd   :   http://www.debian.org/ports/hurd/
   `-    The Hurd wiki     :   http://hurd.gnufans.org/


--- ssmtp.c     2005-01-22 20:09:02.000000000 +0100
+++ ssmtp.c     2005-01-22 20:08:46.000000000 +0100
@@ -38,6 +38,8 @@
 #endif
 #include "ssmtp.h"
 
+/* xgethostname used to replace MAXHOSTNAMELEN */
+#include "xgethostname.h"
 
 bool_t have_date = False;
 bool_t have_from = False;
@@ -59,7 +61,8 @@
 char *auth_method = (char)NULL;                /* Mechanism for SMTP 
authentication */
 char *mail_domain = (char)NULL;
 char *from = (char)NULL;               /* Use this as the From: address */
-char hostname[MAXHOSTNAMELEN] = "localhost";
+/* char hostname[MAXHOSTNAMELEN] = "localhost";  */
+char *hostname = "localhost";
 char *mailhost = "mailhub";
 char *minus_f = (char)NULL;
 char *minus_F = (char)NULL;
@@ -140,7 +143,8 @@
 */
 void dead_letter(void)
 {
-       char path[(MAXPATHLEN + 1)], buf[(BUF_SZ + 1)];
+       /* char path[(MAXPATHLEN + 1)], */
+       char buf[(BUF_SZ + 1)];
        struct passwd *pw;
        uid_t uid;
        FILE *fp;
@@ -148,6 +152,8 @@
        uid = getuid();
        pw = getpwuid(uid);
 
+       char path[(sizeof(pw->pw_dir) + 1)];
+
        if(isatty(fileno(stdin))) {
                if(log_level > 0) {
                        log_event(LOG_ERR,
@@ -218,19 +224,23 @@
 */
 char *basename(char *str)
 {
-       char buf[MAXPATHLEN +1], *p;
+       /* char buf[MAXPATHLEN +1], *p; */
+       char buf[sizeof(str) +1], *p;
 
        if((p = strrchr(str, '/'))) {
-               if(strncpy(buf, ++p, MAXPATHLEN) == (char *)NULL) {
+               /* if(strncpy(buf, ++p, MAXPATHLEN) == (char *)NULL) { */
+               if(strncpy(buf, ++p, sizeof(str)) == (char *)NULL) {
                        die("basename() -- strncpy() failed");
                }
        }
        else {
-               if(strncpy(buf, str, MAXPATHLEN) == (char *)NULL) {
+               /* if(strncpy(buf, str, MAXPATHLEN) == (char *)NULL) { */
+               if(strncpy(buf, str, sizeof(str)) == (char *)NULL) {
                        die("basename() -- strncpy() failed");
                }
        }
-       buf[MAXPATHLEN] = (char)NULL;
+       /* buf[MAXPATHLEN] = (char)NULL; */
+       buf[sizeof(str)] = (char)NULL;
 
        return(strdup(buf));
 }
@@ -830,8 +840,9 @@
                                }
                        }
                        else if(strcasecmp(p, "HostName") == 0) {
-                               if(strncpy(hostname, q, MAXHOSTNAMELEN) == 
NULL) {
-                                       die("parse_config() -- strncpy() 
failed");
+                               /* if(strncpy(hostname, q, MAXHOSTNAMELEN) == 
NULL) { */
+                               if(strcpy(hostname, q) == NULL) { 
+                                       die("parse_config() -- strcpy() 
failed");
                                }
 
                                if(log_level > 0) {
@@ -1885,9 +1896,16 @@
        /* Set the globals */
        prog = basename(argv[0]);
 
+       hostname = xgethostname();
+       if(!hostname) {
+               perror("xgethostname");
+               die("Cannot get the name of this machine");
+       }
+       /* Don't need this anymore 
        if(gethostname(hostname, MAXHOSTNAMELEN) == -1) {
                die("Cannot get the name of this machine");
        }
+       */
        new_argv = parse_options(argc, argv);
 
        exit(ssmtp(new_argv));

Attachment: signature.asc
Description: Digital signature


reply via email to

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