Skip to main content

Thread: Execute program without sudo


i have program reads /dev/usb device requires sudo run it. there way execute without using sudo?

code:
#include <stdlib.h>  #include <stdio.h>  #include <sys/ioctl.h>  #include <sys/types.h>  #include <sys/stat.h>  #include <asm/types.h>  #include <fcntl.h>  #include <unistd.h>  #include <linux/hiddev.h>    #define ev_num 5      int main (int argc, char **argv) {      int fd = -1;    int i;    struct hiddev_event ev[ev_num];    char name[100];      if (argc != 2) {      fprintf(stderr, "usage: %s hiddevice - /dev/usb/hiddev0\n", argv[0]);      exit(1);    }    if ((fd = open(argv[1], o_rdonly)) < 0) {      perror("hiddev open");      exit(1);    }      ioctl(fd, hidiocgname(100), name);      printf("ok name = %s\n", name);        printf("reading values .. \n");          read(fd, ev, sizeof(struct hiddev_event) * ev_num);        (i = 1; < 2;i++) {            printf("%d\n", ev[i].value);      }      close(fd);      exit(0);  }

solution: http://ubuntuforums.org/showthread.php?t=1878346

you should make udev rule allows permissions specific usb device. in trend

kernel=="hiddev*", mode="0666", name="usb/%k"

"hiddev" usb device (see how yours named under
/sys/bus/usb/devices/ )

place in /etc/udev/rules.d directory file 99_my.rules

let them have effect easy reboot.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Execute program without sudo


Ubuntu

Comments

Popular posts from this blog

Thread: Can not create raid array: mdadm: no raid-devices specified.

Thread: HOW TO: Package and theme GTK+ / Gtkmm apps in Linux for Windows

Thread: Twinview issues