Make dwge(4) call mii_tick(9)

2019-07-02 Thread Mark Kettenis
Such that it detects link status changes.

ok?


Index: dev/ic/dwc_gmac.c
===
RCS file: /cvs/src/sys/dev/ic/dwc_gmac.c,v
retrieving revision 1.11
diff -u -p -r1.11 dwc_gmac.c
--- dev/ic/dwc_gmac.c   30 Dec 2018 20:11:59 -  1.11
+++ dev/ic/dwc_gmac.c   2 Jul 2019 22:10:46 -
@@ -78,6 +78,7 @@ void dwc_gmac_ifmedia_sts(struct ifnet *
 int dwc_gmac_miibus_read_reg(struct device *, int, int);
 void dwc_gmac_miibus_write_reg(struct device *, int, int, int);
 void dwc_gmac_miibus_statchg(struct device *);
+void dwc_gmac_tick(void *);
 
 int dwc_gmac_reset(struct dwc_gmac_softc *);
 void dwc_gmac_write_hwaddr(struct dwc_gmac_softc *, uint8_t *enaddr);
@@ -200,6 +201,8 @@ dwc_gmac_attach(struct dwc_gmac_softc *s
goto fail;
}
 
+   timeout_set(>sc_tick, dwc_gmac_tick, sc);
+
/*
 * Prepare interface data
 */
@@ -741,6 +744,19 @@ dwc_gmac_miibus_statchg(struct device *d
AWIN_GMAC_MAC_CONF, conf);
 }
 
+void
+dwc_gmac_tick(void *arg)
+{
+   struct dwc_gmac_softc *sc = arg;
+   int s;
+
+   s = splnet();
+   mii_tick(>sc_mii);
+   splx(s);
+
+   timeout_add_sec(>sc_tick, 1);
+}
+
 int
 dwc_gmac_init(struct ifnet *ifp)
 {
@@ -781,6 +797,8 @@ dwc_gmac_init(struct ifnet *ifp)
ifq_clr_oactive(>if_snd);
ifp->if_flags |= IFF_RUNNING;
 
+   timeout_add_sec(>sc_tick, 1);
+
return 0;
 }
 
@@ -835,6 +853,8 @@ void
 dwc_gmac_stop(struct ifnet *ifp, int disable)
 {
struct dwc_gmac_softc *sc = ifp->if_softc;
+
+   timeout_del(>sc_tick);
 
ifp->if_flags &= ~IFF_RUNNING;
ifq_clr_oactive(>if_snd);
Index: dev/ic/dwc_gmac_var.h
===
RCS file: /cvs/src/sys/dev/ic/dwc_gmac_var.h,v
retrieving revision 1.4
diff -u -p -r1.4 dwc_gmac_var.h
--- dev/ic/dwc_gmac_var.h   21 May 2017 11:52:04 -  1.4
+++ dev/ic/dwc_gmac_var.h   2 Jul 2019 22:10:46 -
@@ -90,6 +90,8 @@ struct dwc_gmac_softc {
uint16_t sc_mii_clk;
 
void (*sc_statchg)(struct device *);
+
+   struct timeout sc_tick;
 };
 
 void dwc_gmac_attach(struct dwc_gmac_softc*, uint32_t, int);



Re: ldomctl: improve usage

2019-07-02 Thread Theo de Raadt
Andrew Grillet  wrote:

> I assumed "usage" is printed in response to a failure to give the correct
> combination of command and argument
> and that -h (or help) would give more detail.

well you assumed wrong --- I don't believe we have a single utility in
the tree which behaves that way.  The usage messages are supposed to
remain constant, and one implication of that is to be concise.



Re: ldomctl: improve usage

2019-07-02 Thread Andrew Grillet
I assumed "usage" is printed in response to a failure to give the correct
combination of command and argument
and that -h (or help) would give more detail.
I would like the usage (response to incorrect combination) to be the
"synopsis" while the grouped commands and
their valid arguments is supplied for -h.
Reason being failure to give the correct format is most likely a typo
anyway, while, if an infrequent user, you
might need to check (eg) that download takes a directory, while init-system
takes a file and dump takes nothing.
(I can never remember whether it is init-system or system-init, as I do it
about once a year).
For anything more complex, there is "man".
Would two columns be a solution for those who struggle with scroll back?



On Tue, 2 Jul 2019 at 21:23, Klemens Nanni  wrote:

> Thanks for the input;  I won't persue such verbose usages any longer.
>
> Another attempt was to continue grouping the commands by their arguments:
>
> $ ldomctl -h
> usage:  ldomctl command [argument ...]
> ldomctl delete|select configuration
> ldomctl download directory
> ldomctl dump
> ldomctl list
> ldomctl init-system file
> ldomctl panic|start|status|stop [domain]
>
> But this still seems long enough and even harder to read, so the
> following patch simply cuts it to the synopsis as per the manual:
>
> $ ldomctl -h
> usage: ldomctl command [argument ...]
>
> It contains less information than before, but is actually consistent
> and not incomplete any longer, which bothers me with the current usage.
>
> Feedback? Obections? OK?
>
> Index: ldomctl.c
> ===
> RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 ldomctl.c
> --- ldomctl.c   15 Sep 2018 13:20:16 -  1.21
> +++ ldomctl.c   1 Jul 2019 19:45:59 -
> @@ -157,10 +157,7 @@ main(int argc, char **argv)
>  void
>  usage(void)
>  {
> -   extern char *__progname;
> -
> -   fprintf(stderr, "usage: %s start|stop|panic domain\n", __progname);
> -   fprintf(stderr, "   %s status [domain]\n", __progname);
> +   fprintf(stderr, "usage: %s command [argument ...]\n",
> getprogname());
> exit(EXIT_FAILURE);
>  }
>
>
>


Re: ospfd: point-to-point on ethernet interfaces

2019-07-02 Thread Remi Locherer
ping

On Mon, Jun 24, 2019 at 12:33:16AM +0200, Remi Locherer wrote:
> Diff below adds to ospfd point to point support for Ethernet interfaces.
> I successfully tested this against Junos and FastIron.
> 
> I first made the key word in the config "point-to-point". But then I
> changed to "type p2p". The later would allow for "type nbma" or "type p2mp"
> should we implement these types.
> 
> On Junos it looks like this:
> 
> area 0.0.0.0 {
> interface ge-0/0/1.0 {
> interface-type p2p;
> }
> }
> 
> On FastIron it's similar to IOS:
> 
> interface ethernet 1/2/1
>  ip address 10.10.10.5 255.255.255.0
>  ip ospf area 0
>  ip ospf network point-to-point
> 
> Comments, test reports and OKs are welcome.
> 
> Remi
> 
> 
> Index: interface.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v
> retrieving revision 1.82
> diff -u -p -r1.82 interface.c
> --- interface.c   11 Mar 2018 13:16:49 -  1.82
> +++ interface.c   23 Jun 2019 11:27:57 -
> @@ -190,6 +190,8 @@ if_new(struct kif *kif, struct kif_addr 
>   if (kif->flags & IFF_BROADCAST &&
>   kif->flags & IFF_MULTICAST)
>   iface->type = IF_TYPE_BROADCAST;
> + if (iface->p2p)
> + iface->type = IF_TYPE_POINTOPOINT;
>   if (kif->flags & IFF_LOOPBACK) {
>   iface->type = IF_TYPE_POINTOPOINT;
>   iface->passive = 1;
> @@ -351,6 +353,9 @@ if_act_start(struct iface *iface)
>   orig_rtr_lsa(iface->area);
>   return (0);
>   }
> +
> + if (iface->p2p)
> + iface->type = IF_TYPE_POINTOPOINT;
>  
>   switch (iface->type) {
>   case IF_TYPE_POINTOPOINT:
> Index: ospfd.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/ospfd.c,v
> retrieving revision 1.108
> diff -u -p -r1.108 ospfd.c
> --- ospfd.c   16 May 2019 05:49:22 -  1.108
> +++ ospfd.c   23 Jun 2019 21:06:44 -
> @@ -911,6 +911,22 @@ merge_interfaces(struct area *a, struct 
>   if_fsm(i, IF_EVT_UP);
>   }
>  
> + if (i->p2p != xi->p2p) {
> + /* re-add interface to enable or disable DR election */
> + if (ospfd_process == PROC_OSPF_ENGINE)
> + if_fsm(i, IF_EVT_DOWN);
> + else if (ospfd_process == PROC_RDE_ENGINE)
> + rde_nbr_iface_del(i);
> + LIST_REMOVE(i, entry);
> + if_del(i);
> + LIST_REMOVE(xi, entry);
> + LIST_INSERT_HEAD(>iface_list, xi, entry);
> + xi->area = a;
> + if (ospfd_process == PROC_OSPF_ENGINE)
> + xi->state = IF_STA_NEW;
> + continue;
> + }
> +
>   strlcpy(i->dependon, xi->dependon,
>   sizeof(i->dependon));
>   i->depend_ok = xi->depend_ok;
> Index: ospfd.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/ospfd.conf.5,v
> retrieving revision 1.57
> diff -u -p -r1.57 ospfd.conf.5
> --- ospfd.conf.5  10 Jun 2019 06:07:15 -  1.57
> +++ ospfd.conf.5  23 Jun 2019 22:10:32 -
> @@ -419,6 +419,9 @@ Router.
>  .It Ic transmit-delay Ar seconds
>  Set the transmit delay.
>  The default value is 1; valid range is 1\-3600 seconds.
> +.It Ic type p2p
> +Set the interface type to point to point.
> +This disables the election of a DR and BDR for the given interface.
>  .El
>  .Sh FILES
>  .Bl -tag -width "/etc/ospfd.conf" -compact
> Index: ospfd.h
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/ospfd.h,v
> retrieving revision 1.104
> diff -u -p -r1.104 ospfd.h
> --- ospfd.h   16 May 2019 05:49:22 -  1.104
> +++ ospfd.h   23 Jun 2019 11:28:24 -
> @@ -363,6 +363,7 @@ struct iface {
>   u_int8_t linkstate;
>   u_int8_t priority;
>   u_int8_t passive;
> + u_int8_t p2p;
>  };
>  
>  struct ifaddrchange {
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/parse.y,v
> retrieving revision 1.98
> diff -u -p -r1.98 parse.y
> --- parse.y   7 Jun 2019 04:57:45 -   1.98
> +++ parse.y   23 Jun 2019 22:04:22 -
> @@ -129,7 +129,7 @@ typedef struct {
>  %token   AREA INTERFACE ROUTERID FIBPRIORITY FIBUPDATE REDISTRIBUTE 
> RTLABEL
>  %token   RDOMAIN RFC1583COMPAT STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
>  %token   AUTHKEY AUTHTYPE AUTHMD AUTHMDKEYID
> -%token   METRIC PASSIVE
> +%token   METRIC P2P PASSIVE
>  %token   HELLOINTERVAL FASTHELLOINTERVAL TRANSMITDELAY
>  %token   RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY
> 

Re: ldomctl: improve usage

2019-07-02 Thread Klemens Nanni
Thanks for the input;  I won't persue such verbose usages any longer.

Another attempt was to continue grouping the commands by their arguments:

$ ldomctl -h
usage:  ldomctl command [argument ...]
ldomctl delete|select configuration
ldomctl download directory
ldomctl dump
ldomctl list
ldomctl init-system file
ldomctl panic|start|status|stop [domain]

But this still seems long enough and even harder to read, so the
following patch simply cuts it to the synopsis as per the manual:

$ ldomctl -h
usage: ldomctl command [argument ...]

It contains less information than before, but is actually consistent
and not incomplete any longer, which bothers me with the current usage.

Feedback? Obections? OK?

Index: ldomctl.c
===
RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.c,v
retrieving revision 1.21
diff -u -p -r1.21 ldomctl.c
--- ldomctl.c   15 Sep 2018 13:20:16 -  1.21
+++ ldomctl.c   1 Jul 2019 19:45:59 -
@@ -157,10 +157,7 @@ main(int argc, char **argv)
 void
 usage(void)
 {
-   extern char *__progname;
-
-   fprintf(stderr, "usage: %s start|stop|panic domain\n", __progname);
-   fprintf(stderr, "   %s status [domain]\n", __progname);
+   fprintf(stderr, "usage: %s command [argument ...]\n", getprogname());
exit(EXIT_FAILURE);
 }
 



cwm.1: describe applications

2019-07-02 Thread Klemens Nanni
I tested cwm(1) as daily driver and it took me a few reads to understand
what "applications".

They're predefined commands you put into cwmrc(5) but cwm(1) does not
mention that, plus the option for it is `command` not `application`, so
searching a tag "application" did not find it;  only the comment in
EXAMPLES showed me how to use it.

I guess there's some better wording for it, but the following diff
links the concept to the actual configuration option.

Feedback? OK?

While here, call the configuration file what it is instead of reusing
the default path (already mentioned somewhere else).

Index: cwm.1
===
RCS file: /cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.64
diff -u -p -r1.64 cwm.1
--- cwm.1   25 Feb 2019 18:07:48 -  1.64
+++ cwm.1   2 Jul 2019 19:10:25 -
@@ -219,6 +219,11 @@ Window is currently focused.
 .It &
 Window is hidden.
 .El
+.Sh APPLICATIONS
+.Nm
+manages a list of applications defined with the
+.Cm command
+configuration option.
 .Sh GROUPS
 .Nm
 has the ability to group windows together, and use the groups to
@@ -242,8 +247,7 @@ Selecting an item will warp to that wind
 Show list of currently defined groups.
 Selecting an item will hide/unhide that group.
 .It Ic M3
-Show list of applications as defined in
-.Pa ~/.cwmrc .
+Show list of applications as defined in the configuration file.
 Selecting an item will spawn that application.
 .El
 .Sh ENVIRONMENT



mg(1) self-insert-char

2019-07-02 Thread Mark Lumsden
In order to test certain aspects of mg, I use the eval-current-buffer 
function. However, that doesn't let me insert a character like 'a' unless 
mg is getting that character from another file or previously existing 
text, somewhere on disk, or in RAM.


This diff allows eval-current-buffer (or an mg startup file) to insert a 
character into a buffer via the self-insert-char function, which emulates 
the self-insert-command. For example:


find-file test
self-insert-char a
self-insert-char b
self-insert-char c
newline
save-buffer

The above would create a file called test (if it didn't exist already) 
with the contents 'abc\n' when invoked via eval-current-buffer (or an mg 
startup file).


The self-insert-command (which is the usual way of inserting a character 
into a buffer - but invoked via a 'normal' key press, not M-x 
self-insert-command) has other functionality when invoked via 
eval-current-buffer (or an mg startup file), see the man page. However, I 
may have missed some functionality of mg that allows a character to be 
inserted into a buffer via eval-current-buffer in this way. If so, please 
let me know. Though this new function does use the code I want to use/test 
(self-insert-command). Also, I have not included a man page addition since 
I am not too sure how useful the new function is to others. However should 
you run mg regress tests, it could be useful.


Comments/criticisms/advice welcome. As are oks.

Mark

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.161
diff -u -p -u -p -r1.161 def.h
--- def.h   2 Jul 2019 16:25:39 -   1.161
+++ def.h   2 Jul 2019 16:56:09 -
@@ -490,6 +490,7 @@ int  rescan(int, int);
 int universal_argument(int, int);
 int digit_argument(int, int);
 int negative_argument(int, int);
+int ask_selfinsert(int, int);
 int selfinsert(int, int);
 int quote(int, int);

Index: funmap.c
===
RCS file: /cvs/src/usr.bin/mg/funmap.c,v
retrieving revision 1.57
diff -u -p -u -p -r1.57 funmap.c
--- funmap.c2 Jul 2019 16:25:39 -   1.57
+++ funmap.c2 Jul 2019 16:56:09 -
@@ -179,6 +179,7 @@ static struct funmap functnames[] = {
{searchagain, "search-again",},
{backsearch, "search-backward",},
{forwsearch, "search-forward",},
+   {ask_selfinsert, "self-insert-char",},
{selfinsert, "self-insert-command",},
{sentencespace, "sentence-end-double-space",},
 #ifdef REGEX
Index: kbd.c
===
RCS file: /cvs/src/usr.bin/mg/kbd.c,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 kbd.c
--- kbd.c   26 Jun 2019 16:54:29 -  1.32
+++ kbd.c   2 Jul 2019 16:56:09 -
@@ -323,6 +323,22 @@ negative_argument(int f, int n)
return (mgwrap(funct, FFNEGARG, nn));
 }

+int
+ask_selfinsert(int f, int n)
+{
+   char*c, cbuf[2];
+
+   if ((c = eread("Insert a character: ", cbuf, sizeof(cbuf),
+   EFNEW)) == NULL || (c[0] == '\0'))
+   return (ABORT);
+
+   key.k_chars[0] = *c;
+   key.k_chars[1] = '\0';
+   key.k_count = 1;
+
+   return (selfinsert(FFRAND, 1));
+}
+
 /*
  * Insert a character. While defining a macro, create a "LINE" containing
  * all inserted characters.



Re: libc: getgrnam: save errno before calling `access`

2019-07-02 Thread Todd C . Miller
On Tue, 02 Jul 2019 09:43:13 -0600, "Theo de Raadt" wrote:

> Yes, that is a problem.  Same problem applies to two other files;
> here are the diffs I propose.

Looks good.  OK millert@

 - todd



Re: libc: getgrnam: save errno before calling `access`

2019-07-02 Thread Theo de Raadt
Richard Ipsum  wrote:

> I was working on an implementation of chown and got an error when
> running it on OpenBSD. It looks like a change[1] might have
> introduced unintended side-effects to getgrnam.
> 
> Without the patch supplied below some chown implementations
> may fail with ENOENT when they should succeed.
> 
> I've tested this change by rebuilding libc from the 6.5 source tree
> installing it on my system and verifying that chown no longer fails.
> Since I'm running 6.5 I'm not able to test 'current', but I did checkout
> the 'current' source tree and the patch applies cleanly.

Yes, that is a problem.  Same problem applies to two other files;
here are the diffs I propose.

Index: gen/getgrent.c
===
RCS file: /cvs/src/lib/libc/gen/getgrent.c,v
retrieving revision 1.47
diff -u -p -u -r1.47 getgrent.c
--- gen/getgrent.c  13 Sep 2018 12:31:15 -  1.47
+++ gen/getgrent.c  2 Jul 2019 15:39:57 -
@@ -197,6 +197,10 @@ DEF_WEAK(getgrgid_r);
 static int
 start_gr(void)
 {
+#ifdef YP
+   int saved_errno = errno;
+#endif
+
if (_gr_fp) {
rewind(_gr_fp);
 #ifdef YP
@@ -214,7 +218,9 @@ start_gr(void)
/*
 * Hint to the kernel that a passwd database operation is happening.
 */
+   saved_errno = errno;
(void)access("/var/run/ypbind.lock", R_OK);
+   errno = saved_errno;
 #endif
 
return((_gr_fp = fopen(_PATH_GROUP, "re")) ? 1 : 0);
Index: gen/getgrouplist.c
===
RCS file: /cvs/src/lib/libc/gen/getgrouplist.c,v
retrieving revision 1.27
diff -u -p -u -r1.27 getgrouplist.c
--- gen/getgrouplist.c  1 Dec 2015 15:08:25 -   1.27
+++ gen/getgrouplist.c  2 Jul 2019 15:40:57 -
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -148,6 +149,9 @@ getgrouplist(const char *uname, gid_t ag
int *skipyp = 
extern struct group *_getgrent_yp(int *);
struct group *grp;
+#ifdef YP
+   int saved_errno;
+#endif
 
/*
 * install primary group
@@ -162,7 +166,9 @@ getgrouplist(const char *uname, gid_t ag
/*
 * Hint to the kernel that a passwd database operation is happening.
 */
+   saved_errno = errno;
(void)access("/var/run/ypbind.lock", R_OK);
+   errno = saved_errno;
 #endif
 
/*
Index: gen/getpwent.c
===
RCS file: /cvs/src/lib/libc/gen/getpwent.c,v
retrieving revision 1.62
diff -u -p -u -r1.62 getpwent.c
--- gen/getpwent.c  21 Aug 2018 20:20:04 -  1.62
+++ gen/getpwent.c  2 Jul 2019 15:38:45 -
@@ -981,6 +981,7 @@ __initdb(int shadow)
 * Hint to the kernel that a passwd database operation is happening.
 */
(void)access("/var/run/ypbind.lock", R_OK);
+   errno = saved_errno;
 
__ypmode = YPMODE_NONE;
__getpwent_has_yppw = -1;



libc: getgrnam: save errno before calling `access`

2019-07-02 Thread Richard Ipsum
Hi,

I was working on an implementation of chown and got an error when
running it on OpenBSD. It looks like a change[1] might have
introduced unintended side-effects to getgrnam.

Without the patch supplied below some chown implementations
may fail with ENOENT when they should succeed.

I've tested this change by rebuilding libc from the 6.5 source tree
installing it on my system and verifying that chown no longer fails.
Since I'm running 6.5 I'm not able to test 'current', but I did checkout
the 'current' source tree and the patch applies cleanly.

Thanks,
Richard

[1]:
https://github.com/openbsd/src/commit/b971f1acd7c34a49359ccefbe512e06f3826a939

Index: getgrent.c
===
RCS file: /cvs/src/lib/libc/gen/getgrent.c,v
retrieving revision 1.47
diff -u -p -u -p -r1.47 getgrent.c
--- getgrent.c  13 Sep 2018 12:31:15 -  1.47
+++ getgrent.c  2 Jul 2019 14:02:02 -
@@ -197,6 +197,8 @@ DEF_WEAK(getgrgid_r);
 static int
 start_gr(void)
 {
+   int saved_errno;
+
if (_gr_fp) {
rewind(_gr_fp);
 #ifdef YP
@@ -214,7 +216,9 @@ start_gr(void)
/*
 * Hint to the kernel that a passwd database operation is happening.
 */
+   saved_errno = errno;
(void)access("/var/run/ypbind.lock", R_OK);
+   errno = saved_errno;
 #endif
 
return((_gr_fp = fopen(_PATH_GROUP, "re")) ? 1 : 0);



Re: smtpd replace mkstemp+fdopen with tmpfile

2019-07-02 Thread Gilles Chehade
On Mon, Jul 01, 2019 at 08:25:02PM +0200, Martijn van Duren wrote:
> No functional change intended, just simplify the code.
> 
> OK?
> 

yes, ok gilles@

> Index: enqueue.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/enqueue.c,v
> retrieving revision 1.115
> diff -u -p -r1.115 enqueue.c
> --- enqueue.c 31 May 2018 21:06:12 -  1.115
> +++ enqueue.c 1 Jul 2019 18:23:02 -
> @@ -171,8 +171,6 @@ enqueue(int argc, char *argv[], FILE *of
>   FILE*fp = NULL, *fout;
>   size_t   sz = 0, envid_sz = 0;
>   ssize_t  len;
> - int  fd;
> - char sfn[] = "/tmp/smtpd.XX";
>   char*line;
>   int  dotted;
>   int  inheaders = 1;
> @@ -269,16 +267,9 @@ enqueue(int argc, char *argv[], FILE *of
>   argc--;
>   }
>  
> - if ((fd = mkstemp(sfn)) == -1 ||
> - (fp = fdopen(fd, "w+")) == NULL) {
> - int saved_errno = errno;
> - if (fd != -1) {
> - unlink(sfn);
> - close(fd);
> - }
> - errc(EX_UNAVAILABLE, saved_errno, "mkstemp");
> - }
> - unlink(sfn);
> + if ((fp = tmpfile()) == NULL)
> + err(EX_UNAVAILABLE, "tmpfile");
> +
>   msg.noheader = parse_message(stdin, fake_from == NULL, tflag, fp);
>  
>   if (msg.rcpt_cnt == 0)
> Index: smtpc.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/smtpc.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 smtpc.c
> --- smtpc.c   15 May 2019 05:02:43 -  1.5
> +++ smtpc.c   1 Jul 2019 18:23:02 -
> @@ -263,19 +263,12 @@ parse_server(char *server)
>  void
>  parse_message(FILE *ifp)
>  {
> - char sfn[] = "/tmp/smtp.XX";
>   char *line = NULL;
>   size_t linesz = 0;
>   ssize_t len;
> - int fd;
>  
> - if ((fd = mkstemp(sfn)) == -1)
> - fatal("mkstemp");
> - unlink(sfn);
> -
> - mail.fp = fdopen(fd, "w+");
> - if ((mail.fp) == NULL)
> - fatal("fdopen");
> + if ((mail.fp = tmpfile()) == NULL)
> + fatal("tmpfile");
>  
>   for (;;) {
>   if ((len = getline(, , ifp)) == -1) {
> Index: smtpctl.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.c,v
> retrieving revision 1.163
> diff -u -p -r1.163 smtpctl.c
> --- smtpctl.c 14 Jan 2019 09:37:40 -  1.163
> +++ smtpctl.c 1 Jul 2019 18:23:02 -
> @@ -1297,20 +1297,10 @@ display(const char *s)
>  
>   if (is_encrypted_fp(fp)) {
>   int i;
> - int fd;
>   FILE   *ofp = NULL;
> - charsfn[] = "/tmp/smtpd.XX";
>  
> - if ((fd = mkstemp(sfn)) == -1 ||
> - (ofp = fdopen(fd, "w+")) == NULL) {
> - int saved_errno = errno;
> - if (fd != -1) {
> - unlink(sfn);
> - close(fd);
> - }
> - errc(1, saved_errno, "mkstemp");
> - }
> - unlink(sfn);
> + if ((ofp = tmpfile()) == NULL)
> + err(1, "tmpfile");
>  
>   for (i = 0; i < 3; i++) {
>   key = getpass("key> ");
> 

-- 
Gilles Chehade @poolpOrg

https://www.poolp.orgpatreon: https://www.patreon.com/gilles