head(1) -c

2016-03-09 Thread Jeremie Courreges-Anglas

Today someone bumped into a port that contained head -c calls.  While
upstream could be prodded to care a bit more about portability, support
for head -c is widespread (GNU coreutils, busybox, FreeBSD, NetBSD) so
I don't see any value in being different.  Plus, tail(1) already has
support for -c.

Comments/ok?

PS: the next diff will remove documentation for the obsolete "-count"
syntax.

Index: head.1
===
RCS file: /cvs/src/usr.bin/head/head.1,v
retrieving revision 1.23
diff -u -p -r1.23 head.1
--- head.1  25 Oct 2015 21:50:32 -  1.23
+++ head.1  9 Mar 2016 20:02:08 -
@@ -37,7 +37,7 @@
 .Nd display first few lines of files
 .Sh SYNOPSIS
 .Nm head
-.Op Fl Ar count | Fl n Ar count
+.Op Fl c Ar count | Fl Ar count | Fl n Ar count
 .Op Ar
 .Sh DESCRIPTION
 The
@@ -56,6 +56,12 @@ is omitted, it defaults to 10.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl c Ar count
+Copy the first
+.Ar count
+bytes of each input file to the standard output.
+.Ar count
+must be a positive decimal integer.
 .It Fl Ar count | Fl n Ar count
 Copy the first
 .Ar count
Index: head.c
===
RCS file: /cvs/src/usr.bin/head/head.c,v
retrieving revision 1.20
diff -u -p -r1.20 head.c
--- head.c  9 Oct 2015 01:37:07 -   1.20
+++ head.c  9 Mar 2016 20:02:08 -
@@ -40,7 +40,7 @@
 static void usage(void);
 
 /*
- * head - give the first few lines of a stream or of each of a set of files
+ * head - give the first few bytes/lines of a stream or of each of a set of 
files
  *
  * Bill Joy UCB August 24, 1977
  */
@@ -51,9 +51,9 @@ main(int argc, char *argv[])
FILE*fp;
longcnt;
int ch, firsttime;
-   longlinecnt = 10;
+   longcount = 10;
char*p = NULL;
-   int status = 0;
+   int dobytes = 0, status = 0;
 
if (pledge("stdio rpath", NULL) == -1)
err(1, "pledge");
@@ -66,13 +66,18 @@ main(int argc, char *argv[])
argv++;
}
 
-   while ((ch = getopt(argc, argv, "n:")) != -1) {
+   while ((ch = getopt(argc, argv, "c:n:")) != -1) {
switch (ch) {
+   case 'c':
+   dobytes = 1;
+   p = optarg;
+   break;
case 'n':
+   dobytes = 0;
p = optarg;
break;
default:
-   usage();
+   usage();
}
}
argc -= optind, argv += optind;
@@ -80,9 +85,10 @@ main(int argc, char *argv[])
if (p) {
const char *errstr;
 
-   linecnt = strtonum(p, 1, LONG_MAX, );
+   count = strtonum(p, 1, LONG_MAX, );
if (errstr)
-   errx(1, "line count %s: %s", errstr, p);
+   errx(1, "%s count %s: %s", dobytes ? "bytes" : "lines",
+   errstr, p);
}
 
for (firsttime = 1; ; firsttime = 0) {
@@ -105,10 +111,16 @@ main(int argc, char *argv[])
}
++argv;
}
-   for (cnt = linecnt; cnt && !feof(fp); --cnt)
-   while ((ch = getc(fp)) != EOF)
-   if (putchar(ch) == '\n')
-   break;
+   if (dobytes) {
+   for (cnt = count; cnt && !feof(fp); --cnt)
+   if ((ch = getc(fp)) != EOF)
+   putchar(ch);
+   } else {
+   for (cnt = count; cnt && !feof(fp); --cnt)
+   while ((ch = getc(fp)) != EOF)
+   if (putchar(ch) == '\n')
+   break;
+   }
fclose(fp);
}
/*NOTREACHED*/
@@ -118,6 +130,7 @@ main(int argc, char *argv[])
 static void
 usage(void)
 {
-   fputs("usage: head [-count | -n count] [file ...]\n", stderr);
+   fputs("usage: head [-c count | -count | -n count] [file ...]\n",
+   stderr);
exit(1);
 }


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: cp -i might violate POSIX

2016-03-06 Thread Jeremie Courreges-Anglas
Theo Buehler  writes:

> On Sat, Mar 05, 2016 at 01:41:32AM +0100, Timo Buhrmester wrote:
>> From src/bin/cp/cp.c:
>> >while ((ch = getopt(argc, argv, "HLNPRfailprv")) != -1) 
>> >[...]
>> >case 'i':
>> >iflag = isatty(fileno(stdin));
>> The -i in cp -i is ignored if standard input isn't a tty.
>> 
>> This breaks doing something along the lines of ``yes n | cp -i [...]''
>> (obviously overwriting files that weren't supposed to be overwritten,
>> as well was rendering the only way to stop cp from overwriting existing
>> files ineffective in scripts)
>> 
>> Our man page also doesn't mention this twist.
>> 
>
> So netbsd decided to commit this diff with the following commit message:
>
>   The '-i' flag should work regardless of whether the standard input is
>   a terminal.  The Open Group notes this historic behavior and correctly
>   notes that it doesn't make much sense.  Note also, that mv(1) has
>   always respected its '-i' regardless of whether the standard input is
>   a terminal.
>   
>   From Timo Buhrmester.
>   
>   
> http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/cp/cp.c?rev=1.59=text/x-cvsweb-markup
>
> I can't see any downside to it and if some people were bitten by this,
> why not?

I can't see any downside either.  ok jca@

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE




Re: The Case of Lost TM_ZONE

2016-03-06 Thread Jeremie Courreges-Anglas
Vadim Zhukov  writes:

> 2016-03-06 1:23 GMT+03:00 Christian Weisgerber :
>> > It looks like decided to use TM_ZONE as a wrapper for tm.tm_zone,
>> > until the tm_zone is gone. So, until the later happens (I found
>> > no usage of tm_zone in base, BTW), we should at least use TM_ZONE
>> > consistently. Okay for the patch?
>> 
>> ok naddy@
>> 
>> Note that tm_gmtoff is wrapped the same way by TM_GMTOFF, and there
>> is a similar inconsistent use of tm_gmtoff in wcsftime.c
>
> You're absolutely right. Here is an updated patch.
>
> Since %z relies on tm_gmtoff, all we can do is to expand %z to empty
> string, as specified in strftime(3).
>
> Okay for this version?

yup

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Remove more netinet6 cruft

2016-03-02 Thread Jeremie Courreges-Anglas

Router Renumbering was never supported, prefix ioctls were deprecated
back in 2002, nobody uses them anymore out there.  struct in6_prefix
still uses a few bits from the prefix ioctl code, I've moved those bits
to nd6.h. The last (pointless) use of struct in6_prefixreq was in
rtadvd.

SIOCSIFADDR_IN6, SIOCSIFDSTADDR_IN6 and SIOCSIFNETMASK_IN6 were
introduced as mirrors of their IPv4 counterparts but they never made
sense in IPv6, where there is no such thing as "the first interface
address".

I propose to get rid of all that stuff (in two commits).

The diff below caused no fallout in a bulk ports build (thanks
ajacoutot@).

ok?

Index: sys/netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.184
diff -u -p -r1.184 in6.c
--- sys/netinet6/in6.c  28 Feb 2016 07:15:34 -  1.184
+++ sys/netinet6/in6.c  29 Feb 2016 12:51:57 -
@@ -200,19 +200,6 @@ in6_control(struct socket *so, u_long cm
}
 
switch (cmd) {
-   case SIOCSIFPREFIX_IN6:
-   case SIOCDIFPREFIX_IN6:
-   case SIOCAIFPREFIX_IN6:
-   case SIOCCIFPREFIX_IN6:
-   case SIOCSGIFPREFIX_IN6:
-   case SIOCGIFPREFIX_IN6:
-   log(LOG_NOTICE,
-   "prefix ioctls are now invalidated. "
-   "please use ifconfig.\n");
-   return (EOPNOTSUPP);
-   }
-
-   switch (cmd) {
case SIOCALIFADDR:
case SIOCDLIFADDR:
if (!privileged)
@@ -239,10 +226,7 @@ in6_control(struct socket *so, u_long cm
case SIOCSIFPHYADDR_IN6:
sa6 = >ifra_addr;
break;
-   case SIOCSIFADDR_IN6:
case SIOCGIFADDR_IN6:
-   case SIOCSIFDSTADDR_IN6:
-   case SIOCSIFNETMASK_IN6:
case SIOCGIFDSTADDR_IN6:
case SIOCGIFNETMASK_IN6:
case SIOCDIFADDR_IN6:
@@ -292,15 +276,6 @@ in6_control(struct socket *so, u_long cm
ia6 = NULL;
 
switch (cmd) {
-   case SIOCSIFADDR_IN6:
-   case SIOCSIFDSTADDR_IN6:
-   case SIOCSIFNETMASK_IN6:
-   /*
-* Since IPv6 allows a node to assign multiple addresses
-* on a single interface, SIOCSIFxxx ioctls are deprecated.
-*/
-   return (EINVAL);
-
case SIOCDIFADDR_IN6:
/*
 * for IPv4, we look for existing in_ifaddr here to allow
Index: sys/netinet6/in6_var.h
===
RCS file: /cvs/src/sys/netinet6/in6_var.h,v
retrieving revision 1.60
diff -u -p -r1.60 in6_var.h
--- sys/netinet6/in6_var.h  28 Feb 2016 07:15:34 -  1.60
+++ sys/netinet6/in6_var.h  29 Feb 2016 12:51:57 -
@@ -269,91 +269,6 @@ struct in6_aliasreq {
struct in6_addrlifetime ifra_lifetime;
 };
 
-/* prefix type macro */
-#define IN6_PREFIX_ND  1
-#define IN6_PREFIX_RR  2
-
-/*
- * prefix related flags passed between kernel(NDP related part) and
- * userland command(ifconfig) and daemon(rtadvd).
- */
-struct prf_ra {
-   u_int onlink : 1;
-   u_int autonomous : 1;
-   u_int router : 1;
-   u_int reserved : 5;
-};
-
-struct in6_prflags {
-   struct prf_ra prf_ra;
-   u_char prf_reserved1;
-   u_short prf_reserved2;
-   /* want to put this on 4byte offset */
-   struct prf_rr {
-   u_int decrvalid : 1;
-   u_int decrprefd : 1;
-   u_int reserved : 6;
-   } prf_rr;
-   u_char prf_reserved3;
-   u_short prf_reserved4;
-};
-
-struct  in6_prefixreq {
-   charipr_name[IFNAMSIZ];
-   u_char  ipr_origin;
-   u_char  ipr_plen;
-   u_int32_t ipr_vltime;
-   u_int32_t ipr_pltime;
-   struct in6_prflags ipr_flags;
-   struct  sockaddr_in6 ipr_prefix;
-};
-
-#define PR_ORIG_RA 0
-#define PR_ORIG_RR 1
-#define PR_ORIG_STATIC 2
-#define PR_ORIG_KERNEL 3
-
-#define ipr_raf_onlink ipr_flags.prf_ra.onlink
-#define ipr_raf_auto   ipr_flags.prf_ra.autonomous
-
-#define ipr_statef_onlink  ipr_flags.prf_state.onlink
-
-#define ipr_rrf_decrvalid  ipr_flags.prf_rr.decrvalid
-#define ipr_rrf_decrprefd  ipr_flags.prf_rr.decrprefd
-
-struct in6_rrenumreq {
-   charirr_name[IFNAMSIZ];
-   u_char  irr_origin;
-   u_char  irr_m_len;  /* match len for matchprefix */
-   u_char  irr_m_minlen;   /* minlen for matching prefix */
-   u_char  irr_m_maxlen;   /* maxlen for matching prefix */
-   u_char  irr_u_uselen;   /* uselen for adding prefix */
-   u_char  irr_u_keeplen;  /* keeplen from matching prefix */
-   struct irr_raflagmask {
-   u_int onlink : 1;
-   u_int autonomous : 1;
-   u_int reserved : 6;
-   } irr_raflagmask;
-   u_int32_t irr_vltime;
-   u_int32_t irr_pltime;
-   struct in6_prflags irr_flags;
-   struct  sockaddr_in6 irr_matchprefix;
-   struct 

monitor_fdpass.c: print ssize_t with %zd

2016-02-29 Thread Jeremie Courreges-Anglas

ok?

Index: libexec/ftpd/monitor_fdpass.c
===
RCS file: /cvs/src/libexec/ftpd/monitor_fdpass.c,v
retrieving revision 1.6
diff -u -p -r1.6 monitor_fdpass.c
--- libexec/ftpd/monitor_fdpass.c   12 Nov 2013 04:44:14 -  1.6
+++ libexec/ftpd/monitor_fdpass.c   29 Feb 2016 18:51:38 -
@@ -62,8 +62,8 @@ send_fd(int sock, int fd)
if ((n = sendmsg(sock, , 0)) == -1)
syslog(LOG_WARNING, "send_fd: sendmsg(%d): %m", sock);
if (n != sizeof(int))
-   syslog(LOG_WARNING, "send_fd: sendmsg: expected sent 1 got %ld",
-   (long)n);
+   syslog(LOG_WARNING, "send_fd: sendmsg: expected sent 1 got %zd",
+   n);
 }
 
 int
@@ -94,7 +94,7 @@ recv_fd(int sock)
}
if (n != sizeof(int))
syslog(LOG_WARNING,
-   "recv_fd: recvmsg: expected received 1 got %ld", (long)n);
+   "recv_fd: recvmsg: expected received 1 got %zd", n);
if (result == 0) {
cmsg = CMSG_FIRSTHDR();
if (cmsg == NULL) {
Index: sbin/isakmpd/monitor_fdpass.c
===
RCS file: /cvs/src/sbin/isakmpd/monitor_fdpass.c,v
retrieving revision 1.16
diff -u -p -r1.16 monitor_fdpass.c
--- sbin/isakmpd/monitor_fdpass.c   24 Mar 2008 16:11:08 -  1.16
+++ sbin/isakmpd/monitor_fdpass.c   29 Feb 2016 18:51:38 -
@@ -67,8 +67,7 @@ mm_send_fd(int socket, int fd)
return -1;
}
if (n != 1) {
-   log_error("mm_send_fd: sendmsg: expected sent 1 got %ld",
-   (long)n);
+   log_error("mm_send_fd: sendmsg: expected sent 1 got %zd", n);
return -1;
}
return 0;
@@ -101,8 +100,8 @@ mm_receive_fd(int socket)
return -1;
}
if (n != 1) {
-   log_error("mm_receive_fd: recvmsg: expected received 1 got %ld",
-   (long)n);
+   log_error("mm_receive_fd: recvmsg: expected received 1 got %zd",
+   n);
return -1;
}
cmsg = CMSG_FIRSTHDR();
Index: usr.bin/ssh/monitor_fdpass.c
===
RCS file: /cvs/src/usr.bin/ssh/monitor_fdpass.c,v
retrieving revision 1.20
diff -u -p -r1.20 monitor_fdpass.c
--- usr.bin/ssh/monitor_fdpass.c25 Feb 2015 23:05:47 -  1.20
+++ usr.bin/ssh/monitor_fdpass.c29 Feb 2016 18:51:38 -
@@ -79,8 +79,7 @@ mm_send_fd(int sock, int fd)
}
 
if (n != 1) {
-   error("%s: sendmsg: expected sent 1 got %ld",
-   __func__, (long)n);
+   error("%s: sendmsg: expected sent 1 got %zd", __func__, n);
return -1;
}
return 0;
@@ -123,8 +122,7 @@ mm_receive_fd(int sock)
}
 
if (n != 1) {
-   error("%s: recvmsg: expected received 1 got %ld",
-   __func__, (long)n);
+   error("%s: recvmsg: expected received 1 got %zd", __func__, n);
return -1;
}
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: move ckqueue function to common.c - tweaked and proper diff

2016-02-29 Thread Jeremie Courreges-Anglas

Committed, thanks.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: rtadvd: remove more dead code

2016-02-28 Thread Jeremie Courreges-Anglas
j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:

> j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:
>
>> Alexander Bluhm <alexander.bl...@gmx.net> writes:
>>
>>> On Tue, Feb 09, 2016 at 02:17:18AM +0100, J??r??mie Courr??ges-Anglas wrote:
>>>> 
>>>> - a few *cnt members of struct rainfo aren't used for anything
>>>> - the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
>>>> - prefix_match() and in6a_site_allrouters are remnants from the
>>>>   Renumbering code (now in the Attic)
>>>> 
>>>> ok?
>>>
>>> OK bluhm@
>>>
>>> I think you should also kill the function init_prefix() and move
>>> the remaining 4 lines into make_prefix() in another diff.
>>
>> duh, thanks.  Here's the diff:

Committed,

> The next diff will merge make_prefix/add_prefix and kill the use of
> "struct in6_prefixreq"... in rtadvd.

Index: config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.53
diff -u -p -r1.53 config.c
--- config.c29 Feb 2016 06:37:55 -  1.53
+++ config.c29 Feb 2016 06:40:21 -
@@ -618,8 +618,8 @@ makeentry(char *buf, size_t len, int id,
  * XXX: other parameters of the prefix (e.g. lifetime) ought
  * to be specified.
  */
-static void
-add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr)
+void
+make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
struct prefix *prefix;
u_char ntopbuf[INET6_ADDRSTRLEN];
@@ -628,20 +628,20 @@ add_prefix(struct rainfo *rai, struct in
log_warn("calloc");
return; /* XXX: error or exit? */
}
-   prefix->prefix = ipr->ipr_prefix.sin6_addr;
-   prefix->prefixlen = ipr->ipr_plen;
-   prefix->validlifetime = ipr->ipr_vltime;
-   prefix->preflifetime = ipr->ipr_pltime;
-   prefix->onlinkflg = ipr->ipr_raf_onlink;
-   prefix->autoconfflg = ipr->ipr_raf_auto;
+   prefix->prefix = *addr;
+   prefix->prefixlen = plen;
+   prefix->validlifetime = DEF_ADVVALIDLIFETIME;
+   prefix->preflifetime = DEF_ADVPREFERREDLIFETIME;
+   prefix->onlinkflg = 1;
+   prefix->autoconfflg = 1;
prefix->origin = PREFIX_FROM_DYNAMIC;
 
TAILQ_INSERT_TAIL(>prefixes, prefix, entry);
 
log_debug("new prefix %s/%d was added on %s",
-   inet_ntop(AF_INET6, >ipr_prefix.sin6_addr,
+   inet_ntop(AF_INET6, >prefix,
   ntopbuf, INET6_ADDRSTRLEN),
-   ipr->ipr_plen, rai->ifname);
+   prefix->prefixlen, rai->ifname);
 
/* free the previous packet */
free(rai->ra_data);
@@ -676,29 +676,6 @@ delete_prefix(struct rainfo *rai, struct
free(prefix);
rai->pfxs--;
make_packet(rai);
-}
-
-void
-make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
-{
-   struct in6_prefixreq ipr;
-
-   memset(, 0, sizeof(ipr));
-   if (if_indextoname(ifindex, ipr.ipr_name) == NULL) {
-   log_warn("Prefix added interface No.%d doesn't"
-   " exist. This should not happen!", ifindex);
-   exit(1);
-   }
-   ipr.ipr_prefix.sin6_len = sizeof(ipr.ipr_prefix);
-   ipr.ipr_prefix.sin6_family = AF_INET6;
-   ipr.ipr_prefix.sin6_addr = *addr;
-   ipr.ipr_plen = plen;
-   ipr.ipr_vltime = DEF_ADVVALIDLIFETIME;
-   ipr.ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-   ipr.ipr_raf_onlink = 1;
-   ipr.ipr_raf_auto = 1;
-
-   add_prefix(rai, );
 }
 
 void


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: rtadvd: remove more dead code

2016-02-28 Thread Jeremie Courreges-Anglas
j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:

> Alexander Bluhm <alexander.bl...@gmx.net> writes:
>
>> On Tue, Feb 09, 2016 at 02:17:18AM +0100, J??r??mie Courr??ges-Anglas wrote:
>>> 
>>> - a few *cnt members of struct rainfo aren't used for anything
>>> - the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
>>> - prefix_match() and in6a_site_allrouters are remnants from the
>>>   Renumbering code (now in the Attic)
>>> 
>>> ok?
>>
>> OK bluhm@
>>
>> I think you should also kill the function init_prefix() and move
>> the remaining 4 lines into make_prefix() in another diff.
>
> duh, thanks.  Here's the diff:

The next diff will merge make_prefix/add_prefix and kill the use of
"struct in6_prefixreq"... in rtadvd.

> Index: config.c
> ===
> RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
> retrieving revision 1.52
> diff -u -p -r1.52 config.c
> --- config.c  26 Feb 2016 12:33:30 -  1.52
> +++ config.c  27 Feb 2016 23:13:29 -
> @@ -678,21 +678,6 @@ delete_prefix(struct rainfo *rai, struct
>   make_packet(rai);
>  }
>  
> -/*
> - * Try to get an in6_prefixreq contents for a prefix which matches
> - * ipr->ipr_prefix and ipr->ipr_plen and belongs to
> - * the interface whose name is ipr->ipr_name[].
> - */
> -static int
> -init_prefix(struct in6_prefixreq *ipr)
> -{
> - ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
> - ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
> - ipr->ipr_raf_onlink = 1;
> - ipr->ipr_raf_auto = 1;
> - return 0;
> -}
> -
>  void
>  make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
>  {
> @@ -708,9 +693,11 @@ make_prefix(struct rainfo *rai, int ifin
>   ipr.ipr_prefix.sin6_family = AF_INET6;
>   ipr.ipr_prefix.sin6_addr = *addr;
>   ipr.ipr_plen = plen;
> + ipr.ipr_vltime = DEF_ADVVALIDLIFETIME;
> + ipr.ipr_pltime = DEF_ADVPREFERREDLIFETIME;
> + ipr.ipr_raf_onlink = 1;
> + ipr.ipr_raf_auto = 1;
>  
> - if (init_prefix())
> - return; /* init failed by some error */
>   add_prefix(rai, );
>  }


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: ckqueue functions in lpq and lpd

2016-02-27 Thread Jeremie Courreges-Anglas
Chris Bennett  writes:

> I am having trouble seeing how these two functions are accomplshinig the
> same thing, checking for control files in the spool.
> These files always start with cf.
>
> in lpd.c
> makes sense to me.
>
> /*
>  * Make sure there's some work to do before forking off a child
>  * XXX - could be common w/ lpq
>  */
> static int
> ckqueue(char *cap)
> {
>   struct dirent *d;
>   DIR *dirp;
>   char *spooldir;
>
>   if (cgetstr(cap, "sd", ) >= 0) {
>   dirp = opendir(spooldir);
>   free(spooldir);
>   } else
>   dirp = opendir(_PATH_DEFSPOOL);
>
>   if (dirp == NULL)
>   return (-1);
>   while ((d = readdir(dirp)) != NULL) {
>   if (d->d_name[0] == 'c' && d->d_name[1] == 'f') {
>   closedir(dirp);
>   return (1); /* found a cf file */
>   }
>   }
>   closedir(dirp);
>   return (0);
> }
>
>
> in lpq.c
> does not make sense to me
>
> /* XXX - could be common w/ lpd */
> static int
> ckqueue(char *cap)
> {
>   struct dirent *d;
>   DIR *dirp;
>   char *spooldir;
>
>   if (cgetstr(cap, "sd", ) >= 0) {
>   dirp = opendir(spooldir);
>   free(spooldir);
>   } else
>   dirp = opendir(_PATH_DEFSPOOL);
>
>   if (dirp == NULL)
>   return (-1);
>   while ((d = readdir(dirp)) != NULL) {
>   if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
>   continue;   /* daemon control files only */
>   closedir(dirp);
>   return (1); /* found something */
>   }
>   closedir(dirp);
>   return (0);
> }
>
>
> the line:
> if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
> is excluding files that start with cf,

The test is true for files names that *do not* start with "cf".  The
action is "continue", ie, restart the loop.  I think the code is
correct.

> yet then has the comment that daemon
> controls files are found.
> They both acccomplish the same thing of returning if there are files in the
> spool.

I agree that the lpq.c version is harder to read.  Patches to:
- use the same test in both lpd and lpq (the one from lpd is nicer)
- move ckqueue() to common_source/
would be welcome IMO.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: rtadvd: remove more dead code

2016-02-27 Thread Jeremie Courreges-Anglas
Alexander Bluhm  writes:

> On Tue, Feb 09, 2016 at 02:17:18AM +0100, J??r??mie Courr??ges-Anglas wrote:
>> 
>> - a few *cnt members of struct rainfo aren't used for anything
>> - the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
>> - prefix_match() and in6a_site_allrouters are remnants from the
>>   Renumbering code (now in the Attic)
>> 
>> ok?
>
> OK bluhm@
>
> I think you should also kill the function init_prefix() and move
> the remaining 4 lines into make_prefix() in another diff.

duh, thanks.  Here's the diff:

Index: config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.52
diff -u -p -r1.52 config.c
--- config.c26 Feb 2016 12:33:30 -  1.52
+++ config.c27 Feb 2016 23:13:29 -
@@ -678,21 +678,6 @@ delete_prefix(struct rainfo *rai, struct
make_packet(rai);
 }
 
-/*
- * Try to get an in6_prefixreq contents for a prefix which matches
- * ipr->ipr_prefix and ipr->ipr_plen and belongs to
- * the interface whose name is ipr->ipr_name[].
- */
-static int
-init_prefix(struct in6_prefixreq *ipr)
-{
-   ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-   ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-   ipr->ipr_raf_onlink = 1;
-   ipr->ipr_raf_auto = 1;
-   return 0;
-}
-
 void
 make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
@@ -708,9 +693,11 @@ make_prefix(struct rainfo *rai, int ifin
ipr.ipr_prefix.sin6_family = AF_INET6;
ipr.ipr_prefix.sin6_addr = *addr;
ipr.ipr_plen = plen;
+   ipr.ipr_vltime = DEF_ADVVALIDLIFETIME;
+   ipr.ipr_pltime = DEF_ADVPREFERREDLIFETIME;
+   ipr.ipr_raf_onlink = 1;
+   ipr.ipr_raf_auto = 1;
 
-   if (init_prefix())
-   return; /* init failed by some error */
add_prefix(rai, );
 }
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: LAC LNS server with OpenBSD

2011-08-17 Thread Jeremie Courreges-Anglas
Gruel Bruno b.gr...@woody.hopto.org writes:

 Hello,

Hi.

 I just want to know if it plan to have a real implitation of L2TP on OpenBSD.

 Is there a work in progress ? or never ?

Without knowing what you already know about OpenBSD and L2TP, it's a bit
difficult to answer. Consider taking a look at /usr/src/usr.sbin/npppd/.

 Thank's

You're welcom'e ;)

-- 
Jeremie Courreges-Anglas - GPG key : 06A11494



<    4   5   6   7   8   9