Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: add a serial-port interface #1301
Conversation
|
Can one of the admins verify this patch? |
|
whitelist this please |
zyga
reviewed
Jun 9, 2016
| + if !ok || path == "" { | ||
| + return fmt.Errorf("serial-port slot must have a path attribute") | ||
| + } | ||
| + |
zyga
Jun 9, 2016
Contributor
We should perhaps run filepath.Clean on the path before checking it (https://golang.org/pkg/path/filepath/#Clean)
zyga
reviewed
Jun 9, 2016
| +func (iface *SerialPortInterface) PermanentSlotSnippet(slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) { | ||
| + switch securitySystem { | ||
| + case interfaces.SecurityAppArmor: | ||
| + if iface.isSerialDevice(slot) { |
zyga
Jun 9, 2016
Contributor
I don't think we should do it, you should just have a path() method that returns the path and panics if it is not vaild. This is only called when the slot is sanitized anyway.
zyga
reviewed
Jun 9, 2016
| + case interfaces.SecurityAppArmor: | ||
| + // Allow write and lock on the file designated by the path. | ||
| + // Dereference symbolic links to file path handed out to apparmor | ||
| + path, err := iface.path(slot) |
zyga
Jun 9, 2016
Contributor
Feel free to panic in iface.path(), this is only called after sanitiazation.
zyga
reviewed
Jun 9, 2016
| +} | ||
| + | ||
| +// isSerialDevice checks if a given serial-port slot has sensible path | ||
| +func (iface *SerialPortInterface) isSerialDevice(slot *interfaces.Slot) bool { |
zyga
Jun 9, 2016
Contributor
I think this can be dropped unless you plan to call it somewhere other than Sanitize()
zyga
reviewed
Jun 9, 2016
| @@ -0,0 +1,246 @@ | ||
| +// -*- Mode: Go; indent-tabs-mode: t -*- | ||
| + |
|
A few minor comments but this is close to landing IMHO. Please add an entry in |
zyga
added
the
Reviewed
label
Jun 9, 2016
|
Can one of the admins verify this patch? |
|
whitelist this branch |
jocave
added some commits
Jun 2, 2016
zyga
reviewed
Jun 20, 2016
| +} | ||
| + | ||
| +func (iface *SerialPortInterface) path(slot *interfaces.Slot) (string, error) { | ||
| + if path, ok := slot.Attrs["path"].(string); ok { |
zyga
Jun 20, 2016
Contributor
Please change path() to return just the string, you don't return any useful errors so that it either "just works" or a panics.
|
retest this please |
|
retest this please |
|
LGTM |
jocave commentedJun 9, 2016
A new builtin interface that allows basic access to serial ports. Uses just AppArmor snippets to provider access to /dev/tty[A-Z]{1,3}[0-9]{1,3}$