diff options
author | Bryan Drewery <bryan@shatow.net> | 2014-02-20 07:17:45 +0400 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2014-02-20 07:17:45 +0400 |
commit | 22954d5db09f732467aa33c7efc25b7d23ac5a7e (patch) | |
tree | c22726da608fd86f7bd03fda776d724f86bf5bb2 /src/libexec | |
parent | 4aab18f060c049bb9063df2a19a2857f7134f580 (diff) |
Add nc wrapper to handle -N required on 10+
Diffstat (limited to 'src/libexec')
-rw-r--r-- | src/libexec/poudriere/nc/nc.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/libexec/poudriere/nc/nc.c b/src/libexec/poudriere/nc/nc.c new file mode 100644 index 00000000..91162e16 --- /dev/null +++ b/src/libexec/poudriere/nc/nc.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2014 Bryan Drewery <bdrewery@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/** + * nc(1) wrapper to deal with -N change in 10+ + */ +int +main(int argc, char **argv) { +#if __FreeBSD_version > 1000030 + int i; + char **argv2; + + argv2 = malloc((argc + 2) * sizeof(*argv2)); + argv2[0] = argv[0]; + /* Add in -N for newer nc to close socket on EOF */ + argv2[1] = "-N"; + if (argc > 1) + memcpy(&argv2[2], &argv[1], (argc-1) * sizeof(*argv2)); + argv2[argc+1] = NULL; + execv("/usr/bin/nc", argv2); +#else + execv("/usr/bin/nc", argv); +#endif + + return 0; +} |