Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in mail-mta/netqmail/files: 1.06-fbsd-utmpx.patch
Date: Mon, 27 May 2013 01:02:37
Message-Id: 20130527010232.776042171D@flycatcher.gentoo.org
1 robbat2 13/05/27 01:02:32
2
3 Added: 1.06-fbsd-utmpx.patch
4 Log:
5 Bug #437386: FreeBSD netqmail support.
6
7 (Portage version: 2.2.0_alpha177/cvs/Linux x86_64, unsigned Manifest commit)
8
9 Revision Changes Path
10 1.1 mail-mta/netqmail/files/1.06-fbsd-utmpx.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-mta/netqmail/files/1.06-fbsd-utmpx.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-mta/netqmail/files/1.06-fbsd-utmpx.patch?rev=1.1&content-type=text/plain
14
15 Index: 1.06-fbsd-utmpx.patch
16 ===================================================================
17 --- qbiff.c.orig 2010-04-06 08:43:28.000000000 -0300
18 +++ qbiff.c 2010-04-06 08:44:35.000000000 -0300
19 @@ -1,13 +1,6 @@
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 -#include <utmp.h>
23 -#ifndef UTMP_FILE
24 -#ifdef _PATH_UTMP
25 -#define UTMP_FILE _PATH_UTMP
26 -#else
27 -#define UTMP_FILE "/etc/utmp"
28 -#endif
29 -#endif
30 +#include <utmpx.h>
31 #include "readwrite.h"
32 #include "stralloc.h"
33 #include "substdio.h"
34 @@ -21,15 +14,12 @@
35 #include "env.h"
36 #include "exit.h"
37
38 -substdio ssutmp;
39 -char bufutmp[sizeof(struct utmp) * 16];
40 -int fdutmp;
41 substdio sstty;
42 char buftty[1024];
43 int fdtty;
44
45 -struct utmp ut;
46 -char line[sizeof(ut.ut_line) + 1];
47 +struct utmpx *ut;
48 +char line[sizeof(ut->ut_line) + 1];
49 stralloc woof = {0};
50 stralloc tofrom = {0};
51 stralloc text = {0};
52 @@ -64,7 +54,7 @@
53 if (!(user = env_get("USER"))) _exit(0);
54 if (!(sender = env_get("SENDER"))) _exit(0);
55 if (!(userext = env_get("LOCAL"))) _exit(0);
56 - if (str_len(user) > sizeof(ut.ut_name)) _exit(0);
57 + if (str_len(user) > sizeof(ut->ut_user)) _exit(0);
58
59 if (!stralloc_copys(&tofrom,"*** TO <")) _exit(0);
60 if (!stralloc_cats(&tofrom,userext)) _exit(0);
61 @@ -89,15 +79,11 @@
62 if (!stralloc_cat(&woof,&text)) _exit(0);
63 if (!stralloc_cats(&woof,"\015\n")) _exit(0);
64
65 - fdutmp = open_read(UTMP_FILE);
66 - if (fdutmp == -1) _exit(0);
67 - substdio_fdbuf(&ssutmp,read,fdutmp,bufutmp,sizeof(bufutmp));
68 -
69 - while (substdio_get(&ssutmp,&ut,sizeof(ut)) == sizeof(ut))
70 - if (!str_diffn(ut.ut_name,user,sizeof(ut.ut_name)))
71 + while ((ut = getutxent()) != NULL)
72 + if (ut->ut_type == USER_PROCESS && !str_diffn(ut->ut_user,user,sizeof(ut->ut_user)))
73 {
74 - byte_copy(line,sizeof(ut.ut_line),ut.ut_line);
75 - line[sizeof(ut.ut_line)] = 0;
76 + byte_copy(line,sizeof(ut->ut_line),ut->ut_line);
77 + line[sizeof(ut->ut_line)] = 0;
78 if (line[0] == '/') continue;
79 if (!line[0]) continue;
80 if (line[str_chr(line,'.')]) continue;