Use Augeas to change kernel audit param fails with multiple title blocks - puppet

This example is supposed to change the kernel line in every title block by adding or setting the audit parameter to 1. It works fine if there is only one title block but if there is more than one it doesn't do anything. Am I missing something?
Puppet Master
augeas-libs.x86_64 1.0.0-5.el6_5.1 #updates
puppet.noarch 2.7.25-2.el6 #epel-6server
puppet-server.noarch 2.7.25-2.el6 #epel-6server
ruby-augeas.x86_64 0.4.1-1.el6 #epel-6server
Puppet Client
yum list installed |grep -i "augeas\|puppet"
augeas-libs.x86_64 1.0.0-10.el6 #anaconda-CentOS-201703281317.x86_64/6.9
puppet.noarch 2.7.26-2.el6 #add-ons_6.9
ruby-augeas.x86_64 0.4.1-1.el6 #epel-6server_6.9
My Class
augeas {
'grub':
context => '/files/etc/grub.conf',
lens => 'grub.lns',
incl => '/etc/grub.conf',
changes => [
'set title[*]/kernel/audit 1',
];
}
My grub file
sudo cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg00-root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
password --encrypted $1$QWxxyxxyxxyxxyx$0eCHxd/
title CentOS (2.6.32-696.23.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.23.1.el6.x86_64 ro root=/dev/mapper/vg00-root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg00/swap LANG=en_US.UTF-8 rd_LVM_LV=vg00/root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto quite rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-696.23.1.el6.x86_64.img
title CentOS 6 (2.6.32-696.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=/dev/mapper/vg00-root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg00/swap LANG=en_US.UTF-8 rd_LVM_LV=vg00/root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto quite rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-696.el6.x86_64.img

The docs for Puppet Augeas imply that set only sets the value for a single key. There is a setm command for changing multiple nodes.
https://puppet.com/docs/puppet/5.1/types/augeas.html

Related

How to re-enable CPU Cores after isolcpus

I'm running some processes on a Jetson NX and I was trying to isolate 3 of the cores so I could use taskset and dedicate them to my python script which incorporated multi processing. To do this, I followed a few tutorials and modified my /boot/extlinux/extlinux.conf file to be:
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyTCU0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 isolcpus=3-5
This worked fine for my needs and when I ran cat /sys/devices/system/cpu/isolated
it outputted 3-5. Now I'm trying to bring back cores 3 and 4, so I modified the extlinux.conf file to say:
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyTCU0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 isolcpus=5
and I rebooted my Jetson. However It still says cores 3-5 are isolated. Is there some other steps I need to take to re-enable these cores?

How to name partitions using fdisk?

I have to create a ArchLinux VM partitionate in 4 subpartitions :
A 9go "root" subpartition
A 5go "home" subpartition
A 400mo non-journalized "boot" subpartition
A 500mo "swap" subpartition
I managed to mount ArchLinux and tagged boot subpartition but now i'm lost... How i'm supposed to name the partitions with fdisk ?
In Linux filesystems are generally labeled at the time of formating. For example:
Code:
mkfs.ext3 /dev/sda3 -l Gentoo
mkswap /dev/sda4 -L Swap
mkfs.reiser /dev/sda2 -L Slackware
The -[L|l] assigns a label to the partition.

Grub configuration for liveCD

I need to create my custom linux liveCD. I used this perfect guide to do this.
In few words: I took linux Mint liveCD, mount it, unpack filesysetm.squashfs, edit it with chroot and pack everything back to iso.
I faced with a problem when tried customize grub settings. For example, I want to set GRUB_TIMEOUT to zero. I can edit grub config file, but i can't run update-grub.
voronwe#sul $ sudo chroot edit
sul # mount -t proc none /proc
sul # mount -t sysfs none /sys
sul # mount -t devpts none /dev/pts
sul # export HOME=/root
sul # export LC_ALL=C
sul # update-grub
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
And i can't mount boot:
sul # mount boot
mount: can't find boot in /etc/fstab or /etc/mtab
sul # cat /etc/fstab
# UNCONFIGURED FSTAB FOR BASE SYSTEM
sul # cat /etc/mtab
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,noexec,nosuid,nodev 0 0
none /proc proc rw 0 0
none /sys sysfs rw 0 0
none /dev/pts devpts rw 0 0
So, do anyone know how can grub configuration be update on liveCD?
I found the way.
There is a file isolinux/isolinux.cfg in the folder, where filesystem.squashfs was unpacked. I delete almost everything to get clear system boot. Minimal necessary settings in this file are:
default livelinux
timeout 0
label livelinux
kernel /casper/vmlinuz
append file=/cdrom/preseed/linuxmint.seed boot=casper initrd=/casper/initrd.lz quiet splash --
Were "timeout" is a GRUB_TIMEOUT * 10. So if you want to wait 1 second in boot menu you should write
timeout 10

Busybox SUID on NFS rootfs

I am building a Linux system from the bottom for a Beagle Bone board. I have compiled the vanilla kernel and built a basic root file system with busybox. The system is booted with U-boot, while the rootfs is located on a Linux PC and exported through NFS:
/path/to/rootfs 10.42.0.17(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
The U-boot bootargs are:
bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:/path/to/rootfs,v3,tcp ip=dhcp
I've encountered a problem when trying to get su working for non-root users. In order to work around the problem people over internet are suggesting to set the suid bit for the busybox binary.
After doing so:
$ sudo chmod u+s busybox
and verifying:
$ ls -la
...
-rwsr-xr-x 1 myuser myuser 1882976 Jan 13 21:47 busybox
...
$ stat -c "%a %n" busybox
4755 busybox
Something went wrong. The kernel is booting and all of the usual messages are displayed, but it is getting stuck at the end, and no login line is displayed. Here are last few lines of the booting sequence:
[ 3.776185] IP-Config: Complete:
[ 3.779656] device=eth0, hwaddr=c8:a0:30:c5:80:e9, ipaddr=10.42.0.17, mask=255.255.255.0, gw=10.42.0.1
[ 3.789877] host=10.42.0.17, domain=, nis-domain=(none)
[ 3.795822] bootserver=10.42.0.1, rootserver=10.42.0.1, rootpath=
[ 3.802492] nameserver0=10.42.0.1
[ 3.871575] VFS: Mounted root (nfs filesystem) on device 0:15.
[ 3.879903] devtmpfs: mounted
[ 3.883713] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
If removing the flag, the things are returning to normal:
....
[ 3.862291] Freeing unused kernel memory: 380K (c07ef000 - c084e000)
10.42.0.17 login:
If setting the flag from within the running shell on the Beagle Bone board itself, the shell is stopping responding right after the chmod is performed.
I suspect it is something to do with the way the NFS is exporting the rootfs, but it's only a guess, so qualified explanation and possible solution would be helpful.
After some research I will answer my question myself. The answer is very simple. In order the above to work, the busybox binary should be owned by root:root. The simplest solution is just to change the ownership.

How to edit FreeBSD .gz bootfile?

I have virtual image of a FreeBSD system and when I mount it I don't see the /etc/ directory and other files, instead is a big loader.gz on the filesystem, that I believe that is extracted during the boot process. I decompressed the loader.gz with gzip and I got it:
$ file loader
loader: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), not stripped
Using grep I'm able to confirm that the files that I need to edit are inside, however I don't know how to edit it. I tried to mount it without success. How can I modify the contents of loader.gz and use it again?
Can you please give me an example?
I have a Linux system and a Mac to install tools and this FreeBSD image.
Please, help me.
The loader program is generally the last stage of the kernel bootstrapping process.
A recent image should have another signature. e.g. for a memory stick image;
> file tmp/FreeBSD-10.0-RELEASE-amd64-memstick.img
tmp/FreeBSD-10.0-RELEASE-amd64-memstick.img: Unix Fast File system
[v1] (little-endian), last mounted on ,
last written at Fri Jan 17 00:24:02 2014,
clean flag 1, number of blocks 681040, number of data blocks 679047,
number of cylinder groups 13, block size 8192, fragment size 1024,
minimum percentage of free blocks 8, rotational delay 0ms,
disk rotational speed 60rps, TIME optimization
Mounting an image on FreeBSD:
# mdconfig -a -t vnode -f tmp/FreeBSD-10.0-RELEASE-amd64-memstick.img -u 1
# mount /dev/md1a /mnt/root/
(Linux has the same capability, I just don't remember what its called.)
This image contains loader in the boot/ directory:
# ls /mnt/root/
.cshrc ERRATA.TXT README.TXT boot/ lib/ proc/ sys#
.profile HARDWARE.HTM RELNOTES.HTM dev/ libexec/ rescue/ tmp/
COPYRIGHT HARDWARE.TXT RELNOTES.TXT docbook.css media/ root/ usr/
ERRATA.HTM README.HTM bin/ etc/ mnt/ sbin/ var/
# ls /mnt/root/boot/
beastie.4th check-password.4th gptzfsboot menu.4th support.4th
boot color.4th kernel/ menu.rc userboot.so
boot0 defaults/ loader* menusets.4th version.4th
boot0sio delay.4th loader.4th modules/ zfs/
boot1 device.hints loader.help pmbr zfsboot
boot2 firmware/ loader.rc pxeboot zfsloader*
brand.4th frames.4th mbr screen.4th
cdboot gptboot menu-commands.4th shortcuts.4th
On my FreeBSD 10 system, loader has another signature;
/boot/loader: FreeBSD/i386 demand paged executable

Resources