Merge pull request #145 from lakinduakash/dev

Introduce polkit policies
This commit is contained in:
Lakindu Akash 2021-02-20 20:42:56 +05:30 committed by GitHub
commit a8c4110597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 7 deletions

View File

@ -120,8 +120,6 @@ Start the hotspot service on startup (using your saved configuration) with:
systemctl enable create_ap
### Tested with Ubuntu from 16.04 to 20.04. If any issue is found, file an issue on github.
## Contributing
If you found a bug or you have an idea about improving this make an issue. Even a small contribution make open source world more beautiful.
@ -135,7 +133,7 @@ FreeBSD
Copyright (c) 2013, oblique
Copyright (c) 2020, lakinduakash
Copyright (c) 2021, lakinduakash
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flakinduakash%2Flinux-wifi-hotspot.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Flakinduakash%2Flinux-wifi-hotspot?ref=badge_large)

View File

@ -48,6 +48,8 @@ install: $(ODIR)/wihotspot-gui
install -Dm644 desktop/icons/hotspot@512.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/512x512/apps/wihotspot.png
install -Dm644 desktop/icons/hotspot.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/wihotspot.svg
install -Dm644 desktop/wifihotspot.desktop $(DESTDIR)$(PREFIX)/share/applications/$(APP_NAME).desktop
install -Dm644 scripts/policies/polkit.rules $(DESTDIR)$(PREFIX)/share/polkit-1/rules.d/90-org.opensuse.policykit.wihotspot.rules
install -Dm644 scripts/policies/polkit.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/org.opensuse.policykit.wihotspot.policy
install -Dm755 $(ODIR)/wihotspot-gui $(DESTDIR)$(BINDIR)/$(APP_GUI_BINARY)
cd scripts && $(MAKE) install
@ -59,6 +61,8 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/512x512/apps/wihotspot.png
rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/wihotspot.svg
rm -f $(DESTDIR)$(PREFIX)/share/applications/$(APP_NAME).desktop
rm -f $(DESTDIR)$(PREFIX)/share/polkit-1/rules.d/90-org.opensuse.policykit.wihotspot.rules
rm -f $(DESTDIR)$(PREFIX)/share/polkit-1/actions/org.opensuse.policykit.wihotspot.policy
rm -f $(DESTDIR)$(BINDIR)/$(APP_GUI_BINARY)
cd scripts && $(MAKE) uninstall

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<action id="org.opensuse.policykit.wihotspot-gui">
<message>Authentication is required to run the Wihotspot</message>
<icon_name>wihotspot</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate
key="org.freedesktop.policykit.exec.path">/usr/bin/wihotspot-gui</annotate>
<annotate
key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
<action id="org.opensuse.policykit.create-ap">
<message>Authentication is required to run the Wihotspot</message>
<icon_name>wihotspot</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate
key="org.freedesktop.policykit.exec.path">/usr/bin/create_ap</annotate>
<annotate
key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

View File

@ -0,0 +1,11 @@
/* Allow users in admin group to run GParted without authentication */
polkit.addRule(function(action, subject) {
if ( action.id == "org.opensuse.policykit.create-ap" ) {
if (subject.isInGroup("sudo")) {
return polkit.Result.YES;
} else {
return polkit.Result.AUTH_ADMIN;
}
}
});

View File

@ -1,4 +1,4 @@
#!/bin/sh
# Start wihotspot-gui as root user
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot-gui
# Start wihotspot-gui
/usr/bin/wihotspot-gui

View File

@ -9,7 +9,7 @@
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
<property name="program_name">Linux Wifi Hotspot</property>
<property name="version">3.7.0</property>
<property name="version">4.0.0</property>
<property name="copyright" translatable="yes">(c) lakinduakash 2021</property>
<property name="comments" translatable="yes">For more info visit
https://github.com/lakinduakash/linux-wifi-hotspot</property>

View File

@ -167,7 +167,7 @@ void write_accepted_macs(char* filename, char* accepted_macs){
printf("mac filter file %s \n",filename);
snprintf(cmd_write_mac,BUFSIZE,"%s '%s' %s %s","echo", accepted_macs, "| sudo tee", filename);
snprintf(cmd_write_mac,BUFSIZE,"%s '%s' %s %s","echo", accepted_macs, "| pkexec -u root tee", filename);
int r=system(cmd_write_mac);
}