OpenBSD

Bloated echo command

做~自己de王妃 提交于 2019-12-18 11:57:25
问题 Look at the following implementations of the "echo" command: http://bxr.su/o/bin/echo/echo.c (OpenBSD) http://bxr.su/d/bin/echo/echo.c (DragonFly) http://bxr.su/n/bin/echo/echo.c (NetBSD) http://bxr.su/f/bin/echo/echo.c (FreeBSD) http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/echo.c (GNU) As you go down the list, I'm sure you'll notice the increasing bloat in each implementation. What is the point of a 272 line echo program? 回答1: In their article 'Program Design in the UNIX

openbsd: limit network bandwidth

為{幸葍}努か 提交于 2019-12-11 20:01:32
问题 I have task: " Develop the program on JavaEE(simple web application using Servlet/JSP techlogies), that will be run on 'OpenBSD 5.6. amd64' server and that provides interface for controlling network ports( up / down and limit speed ) " Up/Down is simple: ifup 'interface-name'/ifdown 'inteface-name'. But with 'limit speed' i have some difficulties. I want do this with shal command, but i can't find sample. Only with third-party tools: Wondershaper , Trickle . Related topics: 1, 2 Any ideas? In

list tables and fields of OpenBSD databases/sqlports sqlite3 database

为君一笑 提交于 2019-12-11 05:50:47
问题 How do I get started with an sqlite3 database? For example, there's http://openports.se/databases/sqlports that contains various info about OpenBSD ports; I've installed it on OpenBSD 5.2, and the only file it created, as per /var/db/pkg/sqlports-2.3p0/+CONTENTS , is share/sqlports in /usr/local . % file /usr/local/share/sqlports /usr/local/share/sqlports: SQLite 3.x database How do I know which tables it has, and what fields does each table has? 回答1: The following seems to do the job, with

sed: replace spaces within quotes with underscores

懵懂的女人 提交于 2019-12-07 15:03:37
问题 I have input (for example, from ifconfig run0 scan on OpenBSD) that has some fields that are separated by spaces, but some of the fields themselves contain spaces (luckily, such fields that contain spaces are always enclosed in quotes). I need to distinguish between the spaces within the quotes, and the separator spaces. The idea is to replace spaces within quotes with underscores. Sample data: %cat /tmp/ifconfig_scan | fgrep nwid | cut -f3 nwid Websense chan 6 bssid 00:22:7f:xx:xx:xx 59dB

Why does OpenBSD's G++ make system headers default to C linkage?

て烟熏妆下的殇ゞ 提交于 2019-12-06 07:28:18
I am porting some code to OpenBSD 5.0 and I ran into this very strange problem. My build settings use -isystem /usr/local/include . It is hard to remember but I believe I did that to avoid masses of compiler warnings from my use of -Wall on system types -- like BSD -- that install Boost to /usr/local/include . This seems to work great on FreeBSD. So take the following program: #include <boost/array.hpp> int main() { return 0; } Then build it with: c++ -O2 -pipe -isystem /usr/local/include -std=c++98 -o test test.cxx On OpenBSD I discovered that I get: In file included from /usr/include/g++

What is the purpose of format specifier “%qd” in `printf()`?

青春壹個敷衍的年華 提交于 2019-12-05 09:58:56
问题 I saw format specifier %qd when browsing github code. Then I checked in GCC compiler, it's working fine. #include <stdio.h> int main() { long long num = 1; printf("%qd\n", num); return 0; } What is the purpose of format specifier %qd in printf() ? 回答1: Though only a few articles come about %qd in a normal google search, for future reference, this answer is the compilation of my own research, rsp's answer and little discussions here in the comments section by Jonathan Leffler and StoryTeller.

How do I get a bash script working on FreeBSD, OpenBSD and Linux without modifying it?

爷,独闯天下 提交于 2019-12-03 13:16:11
Sorry, the headline might be a bit irritating, but I didn't know anything better. Anyway, I want a bash script to work on FreeBSD, OpenBSD and Linux without modifying it, but bash isn't located at the same place in Linux and BSD. So, if I write #!/bin/bash then it won't work on BSD, because the bash shell is located in /usr/local/bin/bash there. Is there any solution to get this script working on both? Or do I really need to ship two scripts with different paths...? Using env in the shebang ( #!/usr/bin/env bash ) should make the script OS agnostic. TGOGAM I like the answer about using #!/usr

Using PacketFilter to transparently proxy packets in OS X

你说的曾经没有我的故事 提交于 2019-12-03 08:35:33
问题 There is a cool utility out there called sshuttle. It has depended on ipfw to forward packets in the past. It appears that ipfw is mostly broken in Mavericks and the advice is to use PacketFilter for this now. I've spent most of the day looking at PacketFilter and it appears ipfw has a feature that PacketFilter does not support (hope I'm wrong about this). The following rule: ipfw -q add 12300 fwd 127.0.0.1,12300 tcp from any to any not ipttl 42 keep-state setup will forward all traffic to

Using PacketFilter to transparently proxy packets in OS X

笑着哭i 提交于 2019-12-02 22:29:23
There is a cool utility out there called sshuttle . It has depended on ipfw to forward packets in the past. It appears that ipfw is mostly broken in Mavericks and the advice is to use PacketFilter for this now. I've spent most of the day looking at PacketFilter and it appears ipfw has a feature that PacketFilter does not support (hope I'm wrong about this). The following rule: ipfw -q add 12300 fwd 127.0.0.1,12300 tcp from any to any not ipttl 42 keep-state setup will forward all traffic to 127.0.0.1 (localhost) port 12300. It does not, however, change the destination IP or port in the TCP

httpd 443端口为什么只监听在tcp6上

一曲冷凌霜 提交于 2019-11-28 18:45:18
系统redhat7 ,httpd已经启动 [root@rhcsa conf.d]# netstat -tnpl | grep 443 tcp6 0 0 :::443 :::* LISTEN 1229/httpd 为什么如上命令只显示tcp6,而没有tcp ? --------------------------------------------------- 监听了tcp6后,tcp也可以用的。 虽然这个只显示了IPv6的端口监听,但并不代表只接受IPv6的连接,实际上,apache会以mapped address (::FFFF:a.b.c.d) 方式来接受IPv4的连接。除了少部分平台上,例如FreeBSD,NetBSD,OpenBSD之外, Apache在编译时,默认启用了 --enable-v4-mapped 选项。所以,Apache会同时接受IPv6和IPv4的连接请求。 除非是 IPV6_V6ONLY 模式开启,才需要两个不同的socket来分别监听IPv6和IPv4.IPV6_V6ONLY模式可以通过 sysctl net.ipv6.bindv6only 来控制,默认是关闭的。如果你实在愿意在netstat中只看到IPv4端口的监听,那么,你可以修apachezhttp.conf 中,将 Listen 80 修改为 Listen 0.0.0.0:80 具体信息