Merge pull request #45 from lakinduakash/44-patch

Now config file is always writen to /etc/wh.config
This commit is contained in:
Lakindu Akash 2020-05-06 16:31:37 +05:30 committed by GitHub
commit 18ef10995c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 10 deletions

View File

@ -49,5 +49,6 @@ add_custom_target(uninstall_build
COMMAND rm -rf $ENV{DESTDIR}${appdir}/${PROJECT_NAME}
COMMAND rm -f $ENV{DESTDIR}${appbin}/${PROJECT_NAME}
COMMAND rm -f $ENV{DESTDIR}${appdir}/applications/${PROJECT_NAME}.desktop
COMMAND rm -f $ENV{DESTDIR}${appdir}/${PROJECT_NAME}/${PROJECT_NAME}.desktop
COMMENT Unstalling files...
)

View File

@ -2,7 +2,7 @@
Type=Application
Name=WifiHotspot
Icon=/usr/share/wihotspot/hotspot.png
Exec=sh -c 'pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY sudo /usr/bin/wihotspot'
Exec=sh -c 'env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot'
Terminal=false
Categories=System
Keywords=Hotspot;WiFi

View File

@ -12,6 +12,7 @@ install:
[ ! -d /lib/systemd/system ] || install -Dm644 create_ap.service $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
install -Dm644 bash_completion $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
echo 'ALL ALL=NOPASSWD: /usr/bin/create_ap' | sudo EDITOR='tee -a' visudo -f /etc/sudoers.d/create_ap
uninstall:
@ -20,3 +21,4 @@ uninstall:
[ ! -f /lib/systemd/system/create_ap.service ] || rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
rm -f $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
rm -f /etc/sudoers.d/create_ap

View File

@ -0,0 +1,2 @@
#Execute create_ap without asking password
echo 'ALL ALL=NOPASSWD: /usr/bin/create_ap' | sudo EDITOR='tee -a' visudo -f /etc/sudoers.d/create_ap

View File

@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define BUFSIZE 512
#define SUDO "pkexec --user root"
#define SUDO "sudo"
#define CREATE_AP "create_ap"
#define MKCONFIG "--mkconfig"
@ -98,7 +98,7 @@ const char *build_wh_mkconfig_command(ConfigValues* cv){
const char* a=get_config_file(CONFIG_FILE_NAME);
snprintf(cmd_mkconfig, BUFSIZE, "%s %s %s %s %s %s %s", CREATE_AP, cv->iface_wifi, cv->iface_inet, cv->ssid, cv->pass,MKCONFIG,a);
snprintf(cmd_mkconfig, BUFSIZE, "%s %s %s %s %s %s %s %s",SUDO, CREATE_AP, cv->iface_wifi, cv->iface_inet, cv->ssid, cv->pass,MKCONFIG,a);
if(cv->freq!=NULL){
strcat(cmd_mkconfig," --freq-band ");
@ -184,7 +184,7 @@ const char* build_kill_create_ap_command(char* pid){
static int init_get_running(){
const char* cmd="create_ap --list-running";
const char* cmd="sudo create_ap --list-running";
FILE *fp;
if ((fp = popen(cmd, "r")) == NULL) {

View File

@ -124,12 +124,13 @@ const char* get_config_file(const char* file){
static char a[BUFSIZE];
if ((homedir = getenv("HOME")) == nullptr) {
homedir = getpwuid(getuid())->pw_dir;
}
snprintf(a,BUFSIZE,"%s%s%s",homedir,"/",file);
// if ((homedir = getenv("HOME")) == nullptr) {
// homedir = getpwuid(getuid())->pw_dir;
// }
// snprintf(a,BUFSIZE,"%s%s%s",homedir,"/",file);
snprintf(a,BUFSIZE,"%s",file);
//printf(" from %s \n",a);
return (const char*)a;
}

View File

@ -68,7 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define CONFIG_FILE_NAME ".wh.config"
#define CONFIG_FILE_NAME "/etc/wh.config"
#ifdef __cplusplus
extern "C" {