diff --git a/src/Makefile b/src/Makefile index c33e98c..114276e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/scripts/policies/polkit.policy b/src/scripts/policies/polkit.policy new file mode 100644 index 0000000..abcb5bd --- /dev/null +++ b/src/scripts/policies/polkit.policy @@ -0,0 +1,35 @@ + + + + + + Authentication is required to run the Wihotspot + wihotspot + + auth_admin + auth_admin + yes + + /usr/bin/wihotspot-gui + true + + + + Authentication is required to run the Wihotspot + wihotspot + + auth_admin + auth_admin + yes + + /usr/bin/create_ap + true + + + \ No newline at end of file diff --git a/src/scripts/policies/polkit.rules b/src/scripts/policies/polkit.rules new file mode 100644 index 0000000..e84b065 --- /dev/null +++ b/src/scripts/policies/polkit.rules @@ -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; + } + } +}); \ No newline at end of file diff --git a/src/scripts/wihotspot b/src/scripts/wihotspot index 5d18cad..689b2ea 100755 --- a/src/scripts/wihotspot +++ b/src/scripts/wihotspot @@ -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 diff --git a/src/ui/glade/about.glade b/src/ui/glade/about.glade index 223aa40..9caae72 100644 --- a/src/ui/glade/about.glade +++ b/src/ui/glade/about.glade @@ -9,7 +9,7 @@ dialog center Linux Wifi Hotspot - 3.7.0 + 4.0.0 (c) lakinduakash 2021 For more info visit https://github.com/lakinduakash/linux-wifi-hotspot diff --git a/src/ui/h_prop.c b/src/ui/h_prop.c index e4049d8..7f18987 100644 --- a/src/ui/h_prop.c +++ b/src/ui/h_prop.c @@ -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); }