Skip to main content

Useful Macro that can be a template

· One min read
#define SYSCALL_DEFINE(name) static inline long SYSC_##name
#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)


/*
* Example
*/

/**
* sys_sched_setparam - set/change the RT priority of a thread
* @pid: the pid in question.
* @param: structure containing the new RT priority.
*/
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
{
return do_sched_setscheduler(pid, -1, param);
}

#define SYSCALL_DEFINE(name) static inline long SYSC_##name
#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)


/*
* Example
*/

/**
* sys_sched_setparam - set/change the RT priority of a thread
* @pid: the pid in question.
* @param: structure containing the new RT priority.
*/
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
{
return do_sched_setscheduler(pid, -1, param);
}

How to copy to clipboard in Vim?

· One min read

Requirements

$ vim --version | grep clipboard

+clipboard +keymap +printer +vertsplit
+eval -mouse_jsbterm -sun_workshop +xterm_clipboard

if clipboard is -, then we need install vim-gtk.

for example, on ubuntu:

$ sudo apt install -y vim-gtk

Settings

vim ~/.vimrc

On macOS and Windows set:

$ set clipboard=unnamed

On Linux set (vim 7.3.74+):

$ set clipboard=unnamedplus

Configure Local NTP Server

· One min read
  1. install NTP package
# CentOS
$ sudo yum install -y ntp

# Ubuntu
$ sudo apt install -y ntp
  1. Edit ntp.conf
$ vim /etc/ntp.conf
# Add local server
server 192.168.5.104

# Set access restrict
restrict 192.168.5.0 mask 255.255.254.0 notrap

# Set logfile
logfile /var/log/ntpservice.log
  1. Start NTP server
$ ntpd
  1. Verify NTP Server
$ ntpq -p

Connection ‘ens33‘ is not available on device ens33 because device is strictly unmanaged

· 2 min read

虚拟机开启 ifconfig 没有ens33网卡,无法上网,同时 图形化模式 没有有线连接选项,重启NetworkManager没有用

connection ‘ens33‘ is not available on device ens33 because device is strictly unmanaged
  • 查看托管状态
$ nmcli
docker0: disconnected
"docker0"
bridge, 02:42:74:81:0C:62, sw, mtu 1500

ens33: unmanaged
"Intel 82545EM"
ethernet (e1000), 00:0C:29:C7:13:F3, hw, mtu 1500

lo: unmanaged
"lo"
loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
  • 开启托管
$ nmcli n on
$  nmcli
docker0: disconnected
"docker0"
bridge, 02:42:74:81:0C:62, sw, mtu 1500

ens33: unmanaged
"Intel 82545EM"
ethernet (e1000), 00:0C:29:C7:13:F3, hw, mtu 1500

lo: unmanaged
"lo"
loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
  • reference

Connection ‘ens33‘ is not available on device ens33 because device is strictly unmanaged_victoruu的博客-CSDN博客_device is strictly

docker modify config for running container

· One min read

here is mounted directory

  1. stop docker
$ systemctl stop docker
  1. modify container's config
$ cd /var/lib/docker/container/$containerID/

$ vim config.v2.json

# modify MountPoints

$ vim hsotconfig.json

# modify Binds
  1. start docker
$ systemctl start docker
  1. start container
$ docker start $containerID

Set up Meld as Difftool and Mergetool for Git

· One min read

Configure Meld as Default Git Tools

Edit Config File

  • .gitconfig
[merge]
tool = meld
[mergetool "meld"]
# Choose one of these 2 lines
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"

Commands for Windows and Linux

  • for Windows
$ git config --global diff.tool meld
$ git config --global difftool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
$ git config --global difftool.prompt false

$ git config --global merge.tool meld
$ git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
$ git config --global mergetool.prompt false
  • For Linux
$ git config --global diff.tool meld
$ git config --global difftool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
$ git config --global difftool.prompt false

$ git config --global merge.tool meld
$ git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
$ git config --global mergetool.prompt false

gdb show list

· One min read
define phead
set $ptr = $arg1
plistdata $arg0
end

document phead
Print the first element of a list. E.g., given the declaration
Glist *datalist;
g_list_add(datalist, "Hello");
view the list with something like
gdb> phead char datalist
gdb> pnext char
gdb> pnext char

This macro defines $ptr as the current pointed-to list struct,
and $pdata as the data in that list element.
end

define pnext
set $ptr = $ptr->next
plistdata $arg0
end

document pnext
You need to call phead first; that will set $ptr.
This macro will step forward in the list, then show the value at
that next element. Give the type of the list data as the only argument.

This macro defines $ptr as the current pointed-to list struct, and
$pdata as the data in that list element.
end

insecurity proof failed resolving '$DOMAIN/A/IN'

· One min read

dns forward failed

  • Error message:
28-Oct-2022 09:49:09.251 managed-keys-zone: Key 20326 for zone . is now trusted (acceptance timer complete)
28-Oct-2022 09:49:09.490 resolver priming query complete: success
28-Oct-2022 09:49:14.088 chase DS servers resolving 'bdc500.com/DS/IN': 192.168.5.104#53
28-Oct-2022 09:49:15.003 insecurity proof failed resolving 'bdc500.com/A/IN': 192.168.5.104#53
28-Oct-2022 09:50:46.782 connection refused resolving 'bdc500.com/A/IN': 192.168.5.104#53
28-Oct-2022 09:50:51.070 validating bdc500.com/A: got insecure response; parent indicates it should be secure
28-Oct-2022 09:50:51.070 insecurity proof failed resolving 'bdc500.com/A/IN': 192.168.5.104#53
  • Solution

it is because dnssec without key, the simpliest way is :

dnssec-validation no;