freebsd

execve(“/bin/sh”, 0, 0); in a pipe

爷,独闯天下 提交于 2019-12-03 11:53:23
I have the following example program: #include <stdio.h> int main(int argc, char ** argv){ char buf[100]; printf("Please enter your name: "); fflush(stdout); gets(buf); printf("Hello \"%s\"\n", buf); execve("/bin/sh", 0, 0); } I and when I run without any pipe it works as it should and returns a sh promt: bash$ ./a.out Please enter your name: warning: this program uses gets() which is unsafe. testName Hello "testName" $ exit bash$ But this does not work in a pipe, i think I know why that is, but I cannot figure out a solution. Example run bellow. bash$ echo -e "testName\npwd" | ./a.out Please

Force a core to dump from an active, normally running program on FreeBSD

纵饮孤独 提交于 2019-12-03 09:29:50
I'm writing error handling code for a server on FreeBSD. For extremely serious errors I want to avoid data corruption by immediately terminating. That's easy, exit(3) . Before I exit, I output my relevant variables that led me there. However, ideally, this termination would be accompanied by a .core so that I could fully investigate what got me to this catastrophic (and likely hard to reproduce) state. How can I force this to happen? kill -QUIT process_id will cause a core dump from a running process (assuming that resource limits allow it). Or see man 3 abort for causing a program to dump

Getting GCC in C++11 mode to work on FreeBSD

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: How do I get a working GCC-based C++11 setup on FreeBSD 10? It seems that the standard library that comes with recent GCC versions on FreeBSD is broken. I've installed the port gcc49 and then try to compile this: #include <string> int main () { auto str = std :: to_string ( 42 ); str = std :: to_string ( 42ull ); str = std :: to_string ( 4.2 ); str . clear (); return 0 ; } This gives me an error: g ++ 49 - v - std = c ++ 11 foo . cc Using built - in specs . COLLECT_GCC = g ++ 49 COLLECT_LTO_WRAPPER = /usr/ local / libexec / gcc49 /

Run as different user under FreeBSD [closed]

寵の児 提交于 2019-12-03 08:40:15
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Is there a way in FreeBSD to (being root) run a command as unprivileged user, like nobody? Kind of like reverse of sudo. Oh and considering that 'nobody' has /usr/sbin/nologin as shell - so su is not an option. 回答1: sudo will allow you to run a command as another user. sudo -u nobody <command> will run as nobody

FreeBSD安装scim输入法

六眼飞鱼酱① 提交于 2019-12-03 08:25:39
在登陆时需选择本地语言为chinese(一般在gdm登陆界面输入username后会出现) 一.(1)SCIM安装 安装拼音输入法 # cd /usr/ports/chinese/scim-pinyin # make install clean 安装五笔输入法 # /usr/ports/chinese/scim-tables # make insall clean (2)scim 输入法的环境变量配置 ①查看当前的locale设置: locale ②查看你使用的shell: echo $0 或 cat /etc/passwd ③如果使用的Shell是bash或sh: 请编辑 ~/.profile 文件,在其中的最后,输入如下参数: export LANG=zh_CN.eucCN export LC_CTYPE=zh_CN.eucCN export XMODIFIERS=’@im=scim’ ④如果使用的Shell是csh或tcsh: 请编辑 ~/.cshrc或/etc/csh.cshrc文件,在其中加入如下参数: setenv LANG zh_CN.eucCN setenv LC_CTYPE zh_CN.eucCN setenv XMODIFIERS @im=scim (3)在~/.xinitrc中的 exec /usr/local/bin/gnome-session

[FreeBSD] 双网卡绑定

馋奶兔 提交于 2019-12-03 07:52:53
目的说明 双网卡绑定主要是提供冗余作用。当一个网卡坏掉时,不会影响业务。 操作流程 此文主要是针对FreeBSD操作系统双网卡绑定。 机器IP为 172.207.19.101 双卡绑定双网卡绑定: 加载模块:kldstat查看if_lagg模块是否已加载 如果没有,就需要编辑配置文件/boot/loader.confif_lagg_load="YES" 手工命令加载:kldload if_lagg 编辑配置文件/etc/rc.conf ifconfig_igb0="up" ifconfig_igb1="up" cloned_interfaces="lagg0" ifconfig_lagg0="laggproto failoverlaggport igb0 laggport igb1" ipv4_addrs_lagg0="172.207.19.101/24” 重新加载网络/etc/netstart 查看接口状态ifconfig ———————————————— vi /etc/rc.conf hostname="wsjs-cm-155" ifconfig_bge0="up" ifconfig_bge1="up" ifconfig_bge2="up" ifconfig_bge3="up" cloned_interfaces="lagg0" ifconfig_lagg0=

Anonymous mmap zero-filled?

倖福魔咒の 提交于 2019-12-03 06:24:11
In Linux, the mmap(2) man page explains that an anonymous mapping . . . is not backed by any file; its contents are initialized to zero. The FreeBSD mmap(2) man page does not make a similar guarantee about zero-filling, though it does promise that bytes after the end of a file in a non-anonymous mapping are zero-filled. Which flavors of Unix promise to return zero-initialized memory from anonymous mmaps? Which ones return zero-initialized memory in practice, but make no such promise on their man pages? It is my impression that zero-filling is partially for security reasons. I wonder if any

Shell - one line query

不打扰是莪最后的温柔 提交于 2019-12-03 04:54:50
I need to execute a mysql query in one line using bash. It should be something like this: mysql database --user='root' --password='my-password' < query.file But instead of the < query.file it would like to use a raw query like this: mysql database --user='root' --password='my-password' < UPDATE `database` SET `field1` = '1' WHERE `id` = 1111; Is that possible? Did you try mysql -u root -pmy_password -D DATABASENAME -e "UPDATE `database` SET `field1` = '1' WHERE `id` = 1111;" > output.txt (the > output.txt part can be ignored but, it will be useful to see what was returned by the statement

PostgreSQL In Memory Database

不羁岁月 提交于 2019-12-03 03:49:17
问题 I want to run my PostgreSQL database server from memory. The reason is that on my new server, I have 24 GB of memory, and hardly any of it is used. I know I can run this command to make a ramdisk: mdmfs -s 1024m md2 /mnt And I could theoretically have PostgreSQL store its data there. But the problem with this is that if the server crashes or reboots, the data will be gone. Basically, I want the database to be loaded in memory at all times so that it does not have to go to the hard disk drive

FreeBSD更换国内源

雨燕双飞 提交于 2019-12-03 02:53:24
安装后第一件事就是更换国内源,不然后面安装桌面等没用国内源太慢。 修改 pkg 源 mkdir -p /usr/local/etc/pkg/repos ee /usr/local/etc/pkg/repos/FreeBSD.conf # content of FreeBSD.conf FreeBSD:{ url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly", }#完成后,可以pkg install axel试试效果(axel下面修改ports源时里面会用的的一个小工具)如果没安装成功,从提示上看是系统时间跟网站时间不一致,比如我是19年10月30日23:30,你根据你的时间更改运行date命令调整系统时间:date 1910302330之后再次安装axel,应该就可以成功了。 修改 portsnap 源 ee /etc/portsnap.conf # content of porsnap.conf SERVERNAME=porsnap.tw.freebsd.org#之后运行 portsnap fetch,获取或更新ports架构;因为是第一次用portsnap,之后还需要:portsnap extract之后portsnap update;以后更新ports,就直接portsnap fetch