anatol / booster

Fast and secure initramfs generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to find a config file in /proc

arun54321 opened this issue · comments

commented

On fedora config file is on /boot
image

>sudo booster -output /tmp/booster.img -strip  -debug  -force
unable to find a config file in /proc

Thanks for reporting it. Just to double-check, do you have any /proc/config* files at your system?

Could you please also provide output of ls /boot/?

commented
ls /boot
booster.img			      refind
config-5.16.8-200.fc35.x86_64	      refind_linux.conf
efi				      symvers-5.16.8-200.fc35.x86_64.gz
grub2				      System.map-5.16.8-200.fc35.x86_64
initramfs-5.16.8-200.fc35.x86_64.img  vmlinuz-5.16.8-200.fc35.x86_64
lost+found

ls /proc
1     1130  1257  1299	1404  1436  17	  19	24    27    3217  3407	394   412   4253  4263	4328  46    53	 69	 bootconfig  driver	    kcore	   meminfo	 self		uptime
10    1155  1258  13	1405  1449  1745  1907	2401  2717  325   3411	3946  414   4254  4264	4329  4628  54	 70	 buddyinfo   dynamic_debug  keys	   misc		 slabinfo	version
1029  1186  1260  1308	1406  1453  1763  2	2429  274   3256  35	395   415   4255  4265	4330  463   55	 71	 bus	     execdomains    key-users	   modules	 softirqs	vmallocinfo
1043  1190  1263  1331	1411  1455  1770  200	2483  28    326   36	4     418   4256  4268	4331  4635  6	 805	 cgroups     fb		    kmsg	   mounts	 stat		vmstat
1050  1191  1265  1347	1412  1461  1781  21	2551  29    3288  3671	40    4197  4257  4269	4385  464   609  81	 cmdline     filesystems    kpagecgroup    mtrr		 swaps		zoneinfo
1063  12    1274  1348	1416  1479  1793  22	2553  3     3292  3673	402   42    4258  427	44    47    61	 9	 consoles    fs		    kpagecount	   net		 sys
1072  1201  1279  1353	1425  15    18	  222	2588  3000  33	  37	403   424   4259  4287	445   48    63	 94	 cpuinfo     interrupts     kpageflags	   pagetypeinfo  sysrq-trigger
1074  1203  1287  1369	1427  1521  1875  224	26    303   330   3731	406   425   426   43	45    49    64	 95	 crypto      iomem	    latency_stats  partitions	 sysvipc
11    1226  1293  1388	1428  1565  1879  23	261   31    331   38	407   4250  4260  431	4546  497   65	 951	 devices     ioports	    loadavg	   pressure	 thread-self
1122  1238  1294  14	1432  16    1883  2310	2617  312   332   3808	41    4251  4261  4324	4547  504   66	 acpi	 diskstats   irq	    locks	   schedstat	 timer_list
1126  1253  1295  1402	1434  1684  1888  235	2653  32    34	  39	410   4252  4262  4327	4555  524   68	 asound  dma	     kallsyms	    mdstat	   scsi		 tty

@arun54321 I added a change that implements this /boot/config-* feature. Please check wip branch and let me know if it makes any difference for you.

commented
init - wip ❯ CGO_ENABLED=0 go build -trimpath -mod=readonly -modcacherw
go: github.com/anatol/clevis.go@v0.0.0-20211230012110-04c3cae00cc0 requires
	github.com/anatol/tang.go@v0.0.0-20211230003118-4e3b011304ee requires
	github.com/anatol/clevis.go@v0.0.0-20211227224505-77c31cb75e77 requires
	github.com/anatol/tang.go@v0.0.0-20211208011427-4f66a321d8ef: invalid version: unknown revision 4f66a321d8ef

I don't know whether I'm doing something wrong, I get this error.

Oops sorry. I messed with dependencies earlier. I pushed a fix to wip branch. Please try it again.

commented

go: github.com/anatol/clevis.go@v0.0.0-20220228201535-e211c818efc5 requires
github.com/anatol/tang.go@v0.0.0-20220228200145-7d0d81ac3cf3: missing go.sum entry; to add it:
go mod download github.com/anatol/tang.go

commented

image

Hmm, it works fine for me:

➜  init git:(wip) go version
go version go1.17.7 linux/amd64
➜  init git:(wip) CGO_ENABLED=0 go build -trimpath -mod=readonly -modcacherw
go: downloading github.com/anatol/devmapper.go v0.0.0-20211210164347-f67e20c4e7f7
go: downloading github.com/anatol/smart.go v0.0.0-20220218195151-5ee9e8fa73f0
go: downloading github.com/anatol/luks.go v0.0.0-20211210165108-5d9a15b4f614
go: downloading github.com/anatol/clevis.go v0.0.0-20220228201535-e211c818efc5
go: downloading github.com/anatol/uevent.go v1.0.1-0.20210811163347-3e166d38c549
go: downloading github.com/google/go-tpm v0.3.3
go: downloading github.com/insomniacslk/dhcp v0.0.0-20220119180841-3c283ff8b7dd
go: downloading github.com/vishvananda/netlink v1.1.0
go: downloading github.com/yookoala/realpath v1.0.0
go: downloading golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9
go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
go: downloading golang.org/x/net v0.0.0-20220225172249-27dd8689420f
go: downloading github.com/u-root/uio v0.0.0-20220204230159-dac05f7d2cb4
go: downloading golang.org/x/crypto v0.0.0-20220214200702-86341886e292
go: downloading github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74
go: downloading github.com/lestrrat-go/jwx v1.2.19
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/lestrrat-go/iter v1.0.1
go: downloading github.com/lestrrat-go/backoff/v2 v2.0.8
go: downloading github.com/lestrrat-go/option v1.0.0
go: downloading github.com/lestrrat-go/blackmagic v1.0.0
go: downloading github.com/lestrrat-go/httpcc v1.0.0

What go version do you use?

commented

go version go1.16.14 linux/amd64
I installed it from fedora repos.

I will try again after updating to 1.17.7

I believe clevis.go has been go mod tidy with 1.17 compat.

Does Fedora provide 1.17 go? If not then I will need to downgrade modules to 1.16.

@arun54321 let me know if you was able to get it compiled with 1.17.

commented

I have compiled v1.18 . Does it compile on that?

Yes, it should work with 1.17+.

commented

I don't see the error now. so I think it is working now.

https://0bin.net/paste/xPA+MbcG#kS4L3yChfWKg4VR-Tnl7ajrbCfOItbq7v7MGNEnqQ9I

commented

But booster from this branch does not create initramfs image.

Booster fails for some reason:

enabling virtual console
detected language - '"en_US.UTF-8"'
2022/03/02  exit status 1

I need to look at the code to figure out why there is no any error message for this failure.

Also related question. Is golang 1.17 easily available for Fedore users? Is it ok to use 1.17 specific feature or it is going to be a lot of troubles for Fedora users?

My guess that there is a problem with loadkeys binary. I added a commit that prints more information in case of its failure. @arun54321 please pull the changes from wip and try it one more time. Share your debug output as well.

You can also disable vconsole option in your config file to skip this step.

commented

exit status 1: loadkeys: Unable to open file: "us": No such file or directory
builds fine after disabling vconsole.

exit status 1: loadkeys: Unable to open file: "us": No such file or directory

thanks. What is the content of /etc/vconsole.conf and /etc/locale.conf?

what is output of loadkeys -q -b us?

commented

Also related question. Is golang 1.17 easily available for Fedore users? Is it ok to use 1.17 specific feature or it is going to be a lot of troubles for Fedora users?

I'm using fedora for around a week or 10 days. I don't know about fedora release schedules. For a time being anyone could use my copr repo till it arrives on official repositories.

1.18 is coming in fedora 36 so It should not be problem in future.

commented
/etc ❯ cat vconsole.conf
KEYMAP="us"
FONT="eurlatgr"
/etc ❯ cat locale.conf
LANG="en_US.UTF-8"

commented

It looks like this in terminal.
image

If loadkeys -q -b us works for you then I don't really understand why booster with the same command.

Could you please post output of /etc/booster.yaml? And btw you can paste the text right here, without using screenshots.

commented
compression: zstd
modules: hid_logitech_hidpp,i915,ext4
strip: true
universal: false
vconsole: false

when I paste output on github, they show few unknown symbols because I was using bat as cat in terminal.

Your configuration should call loadkeys -q -b us that runs successfully for you. So I do not really understand why it fails with Unable to open file: "us": No such file or directory.

Could you please reenable vconsole and then run booster with strace -f booster .... to get better understand what exactly booster is doing.

Looking at strace output I see that loadkeys called with correct parameters:

execve("/usr/bin/loadkeys", ["loadkeys", "-q", "-b", "\"us\""], 0xc000d05440 /* 68 vars */ <unfinished ...>

(which is loadkeys -q -b "us")

yet it fails with

[pid 12157] write(2, "loadkeys: ", 10)  = 10
[pid 12157] write(2, "Unable to open file: \"us\": No su"..., 52 <unfinished ...>
[pid 12157] <... write resumed>)        = 52
[pid 12157] write(2, "\n", 1 <unfinished ...>
[pid 12157] <... write resumed>)        = 1
[pid 12157] exit_group(1)               = ?
[pid 12157] +++ exited with 1 +++
[pid 12114] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=12157, si_uid=1000, si_status=1, si_utime=0, si_stime=2} ---
[pid 12128] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=12157, si_uid=1000, si_status=1, si_utime=0, si_stime=0}, WEXITED|WNOWAIT, NULL) = 0
[pid 12128] wait4(12157,  <unfinished ...>
[pid 12128] <... wait4 resumed>[{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, {ru_utime={tv_sec=0, tv_usec=2646}, ru_stime={tv_sec=0, tv_usec=27690}, ...}) = 12157

it is not clear for me why it happens. It might be that Fedora's loadkeys expects some env var or maybe something else.

@arun54321 I actually found one more difference from my setup. The values in your /etc/vconsole.conf have quotes around values (KEYMAP="us"). I added code that strips these quotes. Hopefully it fixes the problem with loadkeys. Please take a look at wip branch.

commented
booster - wip! ❯ g clean -f
Removing generator/booster
Removing init/init
booster - wip ❯ cd generator
generator - wip ❯ CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"
generator - wip ❯ CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
generator - wip ❯ LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
generator - wip ❯ CGO_CPPFLAGS="${CPPFLAGS}" CGO_CFLAGS="${CFLAGS}" CGO_CXXFLAGS="${CXXFLAGS}" CGO_LDFLAGS="${LDFLAGS}"
generator - wip ❯ go build -trimpath \
      -buildmode=pie \
      -mod=readonly \
      -modcacherw \
      -ldflags "-linkmode external -extldflags \"${LDFLAGS}\""

generator - wip! ❯ cd ../init
init - wip ❯ CGO_ENABLED=0 go build -trimpath -mod=readonly -modcacherw
init - wip! ❯ cd ..
booster - wip! ❯ sudo install -Dp -m755 generator/booster "/usr/bin/booster"
[sudo] password for arun: 
booster - wip! ❯ sudo install -Dp -m755 init/init "/usr/lib/booster/init"
booster - wip! ❯ booster build /tmp/a.img -v
increasing open file limit 1024->524288
reading /boot/config-5.16.8-200.fc35.x86_64

no matches found for a device alias 'platform:efivars'
no matches found for a device alias 'acpi:LNXSYSTM:'
enabling virtual console
detected language - 'en_US.UTF-8'
2022/03/05 15:11:12 lstat /lib/libc.so.6: no such file or directory
booster - wip! ❯ 


commented

libc file is in /usr/lib64. How do I compile / fix it properly?

commented

I tried to symlink libc file to the destination.
Now I get open /usr/share/kbd/consolefonts/: no such file or directory

On fedora that folder is in /usr/lib/kbd/consolefonts

Image generation is working now after symlink those missing folders.

enabling virtual console
detected language - 'en_US.UTF-8'
font eurlatgr matched to file /usr/share/kbd/consolefonts/eurlatgr.psfu.gz

/ ❯ file /tmp/a.img
/tmp/a.img: Zstandard compressed data (v0.8+), Dictionary ID: None

libc file is in /usr/lib64. How do I compile / fix it properly?

I added /usr/lib64 path to the booster search list. Booster wip should work for you now without any extra symlinks.

On fedora that folder is in /usr/lib/kbd/consolefonts

I added a patch that makes it easier to configure this folder. Distros could update this path if needed.

051c8a1#diff-1dff658e5bba8c544f3d28aae04581865748e30fd711239342a747f63c4a406bR14

So the fedora package should patch booster path to /usr/lib/kbd/consolefonts

Image generation is working now after symlink those missing folders.

Could you please pull wip branch, remove all the symlinks you've made and then try booster one more time?

open /usr/share/kbd/consolefonts/: no such file or directory

The sourcecode needs to be patched to adjust it to Fedora's defaults.

commented

Should I apply the patch or just pull and build again?
edit: ok

commented

Works well.

Does it boot at Fedora?

Could you please also make a package for Fedora so other people can use the package easily? Is there any way to get this package to Fedora repository?

commented

I don't know to write hooks to which rebuilds image during kernel updates.

commented

Just now tested it. It boots to fedora.

Thank you.

commented

Could you add force and kernelVersion flags to wip branch?

I am trying to write image generation script. It doesn't work due to missing flags.

So far, it works without those flags.

#!/bin/bash -e

# find out all installed kernels
kernels=($(rpm -q kernel-core))

for kernel in "$kernels"; do
    version=$( echo $kernel | sed 's/kernel-core-//g' )
# write to tmp for testing
    booster  build /tmp/booster-${version}.img  &
done

wait

It outputs

unknown flag `k'
unknown flag `f'

The flags start with double hype: --force. Please see man page for more information.

commented
tmp ❯ booster --force build /tmp/booster.img
unknown flag `force'

--force and --kernel-version are build subcommand flags. i.e. you have to put it after the build codeword.

Here is an example of usage https://github.com/anatol/booster/blob/master/packaging/arch/regenerate_images

commented

Thanks. Works fine now.

#!/bin/bash -e

# find out all installed kernels
kernels=($(rpm -q kernel-core))

for kernel in "$kernels"; do
    version=$( echo $kernel | sed 's/kernel-core-//g' )
# write to tmp for testing
    booster  build --force --kernel-version ${version} /tmp/booster-${version}.img   & 
done

wait