Classic confinement request for fastHistory

Hi,

I’d like to request classic confinement for my snap fastHistory.
fastHistory is a python tool integrated with the terminal to store important commands, search them and automatically paste them

This is my GitHub project page:
GitHub: https://github.com/mkcn/fastHistory
GitHub snap branch with the yaml file: https://github.com/mkcn/fastHistory/tree/snap/pkg/snap

Classic confinement:
I would like to request the --classic confinement because the core of this program needs to:

  • read and write ~/.bashrc
  • read and write ~/.zshrc
  • inject commands into the terminal stream without execute them, to emulate the “auto-paste” functionality (see the paste_into_terminal function from /fastHistory/console/consoleUtils.py for more info)
  • copy strings to the clipboard (see the copy_to_clipboard function from /fastHistory/console/consoleUtils.py for more info)

It looks like there is no way to have all these functionalities with snap in strict mode, but if there was I would be glad to try again.

Thanks,
Mirko

I don’t think classic confinement should be required - to read/write dot-files there is the personal-files interface - to copy to the clipboard, it looks like you will need to ship whatever binary is required by the snap (xclip etc) within the snap and then plug the x11 interface it should work.

Can you please give these a try and switch the snap to strict confinement?

Thanks for the hint, the personal-files interface solved the first 2 points.
Unfortunately, the x11 interface did not solve the "auto-paste” problem.
From snappy-debug it looks related to the syscall ioctl (and not to a missing interface).

When the “paste_into_terminal” function of my tool is called with strict OR devmode confinement:

	def paste_into_terminal(data):
		"""
		Fill terminal input with data
		# https://unix.stackexchange.com/a/217390
		"""
		try:
			# check if python version >= 3
			if sys.version_info >= (3,):
				# reverse the automatic encoding and pack into a list of bytes
				data_bytes = (struct.pack('B', c) for c in os.fsencode(data))

			# put each char of data in the standard input of the current terminal
			for c in data_bytes:
				fcntl.ioctl(sys.stdin, termios.TIOCSTI, c)
			# clear output printed by the previous command
			# and leave only the terminal with the submitted input
			sys.stdout.write('\r')
			return [True, None]
		except Exception as e:
			return [False, "your terminal does not support auto-paste: " % e] 

…I get this exception:

"your terminal does not support auto-paste: [Errno 1] Operation not permitted"

Meanwhile snappy-debug prints just this:

mkcn@m-dev:~$ sudo snappy-debug
INFO: Following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
kernel.printk_ratelimit = 0
= Seccomp =
Time: Apr  2 01:36:23
Log: auid=1000 uid=1000 gid=1001 ses=1 subj=snap.fasthistory.fasthistory pid=29877 comm="python3" exe="/snap/fasthistory/x6/usr/bin/python3.6" sig=0 arch=c000003e 16(ioctl) compat=0 ip=0x7ff8de42f317 code=0x50000
Syscall: ioctl

Snap info:

mkcn@m-dev:~$ snap --version
snap    2.49.1
snapd   2.49.1
series  16
ubuntu  20.04
kernel  5.8.0-48-generic

Is there some sort of limitation about the syscall or is there something else I can try?