Comments (4)
With the pull request above, the following beep program works with lower privileges:
use evdev::{Device, EventType, InputEvent, SoundCode};
use std::{fs::OpenOptions, thread, time};
const FILE: &str = "/dev/input/by-path/platform-pcspkr-event-spkr";
pub fn beep(hertz: u16) -> std::io::Result<()> {
Device::try_from(OpenOptions::new().append(true).open(FILE)?)?.send_events(&[InputEvent::new(
EventType::SOUND.0,
SoundCode::SND_TONE.0,
i32::from(hertz),
)])
}
fn main() {
beep(440).expect("could not beep");
thread::sleep(time::Duration::from_millis(500));
beep(880).expect("could not beep");
thread::sleep(time::Duration::from_millis(500));
beep(0).expect("could not beep");
}
Udev rules:
ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", GROUP="beep", MODE="0620"
from evdev.
@conqp I know this is closed, but I was wondering what's the practical security difference between write and append, in this context?
from evdev.
Back in the day when I wrote beep-evdev, it did not work with write and the aforementioned udev rule. I haven't been working with beep-evdev and udev lately, so I don't know what precisely was the issue. Are you able to reproduce it?
Also with the append permission rather than write, a user will never be able to accidentally create the file if it does not exist in the first place, though they'd need write permission on the parent directory anyway. But better be safe than sorry.
from evdev.
@conqp no, I haven't had an issue, I just saw this and wondered what the practical security differences between append and write were.
from evdev.
Related Issues (20)
- Couldn't get key from code: [MediaSelect, LaunchApp1, BrowserFavories, LaunchMail, etc..] HOT 1
- Support `EV_MSC` on uinput devices
- tokio interface documentation isn't being generated
- VirtualDeviceBuilder does not support setting device properties
- Can we have a 0.12.1 in the meantime that can properly compile again? HOT 5
- how to get sysfs of device HOT 1
- Device implements `AsRawFd` but not `AsFd`
- Why do `supported_...` methods return Option ? HOT 2
- (Doc Suggestion) Switch BTN_DPAD_UP to KEY_UP in Virtual Keyboard example
- A link to evtest.rs is broken
- v0.12.1 has the wrong `/dev/` path for `enumerate_dev_nodes_blocking` HOT 7
- Enums are hard to use
- Unable to Device::open the mouse HOT 1
- Use tags
- Keys aren't properly recognized in other keyboards HOT 1
- fetch_events will no longer return an error if the device is disconnected
- Move mouse to an absolute position. HOT 1
- Consider alternative EventStream implementation HOT 4
- Device::into_event_stream() drops device on error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from evdev.