Can't run compiled snapd


#1

I followed the instructions from HACKING.md to download and compile snapd. I think everything went fine, given that I didn’t get any error message.

However, when I run my version of snapd as per the instructions, it won’t start :

$ sudo systemctl stop snapd.service snapd.socket
$ sudo SNAPD_DEBUG=1 SNAPD_DEBUG_HTTP=3 /tmp/snapd
AppArmor status: apparmor is enabled and all features are available
cannot run daemon: cannot obtain snap-seccomp version information: error: unsupported argument "version-info"

Is there something I missed ? Do I have to build snapd in a clean VM ?

I can provide more details, just let me know what you need to see !


#2

did you try make hack?


#3

Or just build snap-seccomp and drop it at the same location as snapd binary.


#4

@mborzecki That didn’t help. Same error.


#5

@chipaca here am I to type that command from ?


#6

if you followed the section called “Building the code locally”, you should be able to make hack from the cmd directory itself.


#7

Ha ! Ok, I’ve done that, it added a file in /etc/apparmor.d but nothing changed.


#8

Oh… strange : with either the snap-seccomp in /tmp (build with go build -o /tmp/snap-seccomp github.com/snapcore/snapd/cmd/snap-seccomp) or the one build with make hack, if I type :

./snap-seccomp version-info

I actually get something : 301522bfb8fff43ba4822c1f787e650e67a1553d 2.3.1 955c3a8a3ed30b9ffea279657e2bc95454d06816d4175de999720e8de028231f

So it’s only when I run snapd that I get the error message…


#9

May I suggest run-snapd-srv? it takes care of a bunch of silly stuff to run snapd directly.

In this case I suspect what you’re hitting is that you have core installed, and the version inside it is somehow newer than the snapd you’re building. I could be wrong, but that’s what I’d try next: run snapd with SNAP_REEXEC=0


#10

We’re progressing !

Running strace -f ... reveals that snapd forks and runs /usr/lib/snapd/snap-seccomp, whatever the value of ${PATH} is :

[pid 32276] execve("/usr/lib/snapd/snap-seccomp", ["/usr/lib/snapd/snap-seccomp", "version-info"], 0xc0002e28c0 /* 19 vars */ <unfinished ...>

#11

Let me look into that. There was a change about finding the internal tools merged recently. It did make things a little harder when trying to run snapd from some random location.

In the meantime, can you copy the snap-seccomp binary you built to /usr/lib/snapd/snap-seccomp ?


#12

Yep ! That worked. I ran sudo SNAPD_DEBUG=1 SNAPD_DEBUG_HTTP=3 ./snapd from inside /usr/lib/snapd, and then installed my snap. I got a bunch of traces in the terminal.

I guess I can CTRL-C that and sudo systemctl start snapd.service snapd.socket to run my own version ?

I have the basis to have a look at how to write an interface now !