Skip to content

Commit 016cb13

Browse files
committed
Adding global read/write permissions to LabJack device rules.
The installer now installs 90-labjack.rules with global read/write permissions to LabJack devices. It also unistalls 10-labjack.rules and no longer cares about adding a user to the adm group.
1 parent d699987 commit 016cb13

File tree

3 files changed

+40
-117
lines changed

3 files changed

+40
-117
lines changed

10-labjack.rules 90-labjack.rules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="labjack_rules_end"
22

33
# LabJack Vendor ID
4-
ATTRS{idVendor}=="0cd5", GROUP="adm"
4+
ATTRS{idVendor}=="0cd5", MODE="0666", GROUP="adm"
55

66
LABEL="labjack_rules_end"

INSTALL.Linux

+34-32
Original file line numberDiff line numberDiff line change
@@ -126,54 +126,56 @@ install the library.
126126
$ make
127127
$ sudo make install
128128

129-
Programs that use the liblabjackusb will need to access the USB device bus
130-
at /dev/bus/usb/, typically with root permission. On Debian-based
131-
distributions, we provide udev rules that allow members of the "adm" group
132-
to access LabJack devices.
129+
Programs that use liblabjackusb will need to access the USB device bus at
130+
/dev/bus/usb/, without root permission. On Debian-based distributions, we
131+
provide udev rules that allow all users to access LabJack devices.
133132

134-
Install The udev Rules
133+
To Install The udev Rules:
135134

136-
To install the udev rules, run the following commands from the root
137-
directory of this package.
135+
To install the udev rules, run the following command from the root
136+
directory of this package:
138137

139-
$ sudo cp 10-labjack.rules /lib/udev/rules.d
140-
$ sudo udevadm control --reload-rules
138+
$ sudo cp 90-labjack.rules /lib/udev/rules.d
141139

142-
Older vesions of udevadm (e.g., the version included in Ubuntu 8.04) use an
143-
underscore instead of a dash: "--reload_rules" instead of "--reload-rules":
140+
Next, reload the udev rules. For instructions, see the section "To Reload the
141+
udev Rules" below.
144142

145-
$ sudo udevadm control --reload_rules
143+
To Set Restrictive Permissions:
146144

147-
On Debian-based distributions, the above two commands are sufficient. If
148-
your distribution does not have udevadm, restart udev or restart your
149-
computer. On a Fedora machine run:
145+
The current udev rules in 90-labjack.rules give LabJack device access to all
146+
users. If you need to restrict permissions, alter 90-labjack.rules or install
147+
custom rules to /etc/udev/rules.d/, which takes priority over
148+
/lib/udev/rules.d/. For example, to restrict usage to members of the adm group:
150149

151-
$ sudo /etc/init.d/udev-post reload
150+
$ sudo cat > /etc/udev/rules.d/90-labjack.rules << EOF
151+
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="labjack_rules_end"
152152

153-
Permissions
153+
# LabJack Vendor ID
154+
ATTRS{idVendor}=="0cd5", MODE="0664", GROUP="adm"
154155

155-
Be sure to add any users that need to use LabJack devices to the "adm"
156-
group. If a user is not in the adm group, they will need to execute
157-
programs that use Exodriver with altered permissions. For example, they will
158-
need to run `sudo ./labjack_program` rather than `./labjack_program`.
156+
LABEL="labjack_rules_end"
159157

160-
To check if the user with username USERNAME is in the adm group, type:
158+
Next, reload the udev rules. For instructions, see the section "To Reload the
159+
udev Rules" below. Also, notice that the MODE is 0664, which is the only
160+
difference between what's installed as /lib/udev/rules.d/90-labjack.rules by
161+
default. For more information about writing udev rules, see "man udev".
161162

162-
$ groups USERNAME
163+
To Reload the udev Rules:
163164

164-
For this command, you can leave USERNAME blank if you are checking what groups
165-
the current user is in.
165+
To reload the udev rules, the following command works on most systems:
166166

167-
If "adm" does not appear in the output, you need to add yourself to the
168-
adm group, as follows.
167+
$ sudo udevadm control --reload-rules
169168

170-
To add a user with username USERNAME to the adm group, run the following
171-
command:
169+
Older vesions of udevadm (e.g., the version included in Ubuntu 8.04) use an
170+
underscore instead of a dash: "--reload_rules" instead of "--reload-rules":
171+
172+
$ sudo udevadm control --reload_rules
172173

173-
$ sudo usermod -a -G adm USERNAME
174+
On Debian-based distributions, the above two commands are sufficient. If
175+
your distribution does not have udevadm, restart udev or restart your
176+
computer. On a Fedora machine run:
174177

175-
For every user that is added to the adm group, they must log out and log
176-
back in for the group changes to take effect. Re-run "groups" to double check.
178+
$ sudo /etc/init.d/udev-post reload
177179

178180

179181
LabJackPython and the Exodriver on Ubuntu 10.04

install.sh

+5-84
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#! /bin/bash
22

3-
RULES=10-labjack.rules
3+
RULES=90-labjack.rules
4+
OLD_RULES=10-labjack.rules
45
RULES_DEST_PRIMARY=/lib/udev/rules.d
56
RULES_DEST_ALTERNATE=/etc/udev/rules.d
6-
GROUP=adm
77
88
TRUE=1
99
FALSE=0
1010
IS_SUCCESS=$TRUE
1111
# Assume these are unneeded until otherwise
1212
NEED_RECONNECT=$FALSE
1313
NEED_RESTART=$FALSE
14-
NEED_RELOG=$FALSE
1514
NO_RULES=$FALSE
1615
NO_RULES_ERR=2
1716

@@ -43,10 +42,6 @@ success ()
4342
fi
4443
if [ $NEED_RESTART -eq $TRUE ]; then
4544
echo "Please manually restart the device rules or restart your computer now."
46-
elif [ $NEED_RELOG -eq $TRUE ]; then
47-
echo "Please log off and log back in for the group changes to take effect. To confirm the group changes have taken effect, enter the command:"
48-
echo " $ groups"
49-
echo "and make sure $GROUP is in the list. (You probably have to log out of your entire account, not just your shell.)"
5045
fi
5146
exit $e
5247
}
@@ -73,6 +68,9 @@ go cd ../
7368
#################
7469
# LabJack Rules #
7570
#################
71+
rm -f $RULES_DEST_PRIMARY/$OLD_RULES
72+
rm -f $RULES_DEST_ALTERNATE/$OLD_RULES
73+
7674
if [ -d $RULES_DEST_PRIMARY ]; then
7775
RULES_DEST=$RULES_DEST_PRIMARY
7876

@@ -117,81 +115,4 @@ else
117115
echo # Finishes previous echo -n
118116
fi
119117

120-
#####################
121-
# Add user to group #
122-
#####################
123-
user=`logname`
124-
125-
in_group=$FALSE
126-
for g in `id -nG $user`; do
127-
if [ "$g" == "$GROUP" ]; then
128-
in_group=$TRUE
129-
break
130-
fi
131-
done
132-
133-
if [ $in_group -eq $TRUE ]; then
134-
# Make sure the user is logged into the adm group
135-
current_groups=$FALSE
136-
for g in `groups $user`; do
137-
if [ "$g" == "$GROUP" ]; then
138-
current_groups=$TRUE
139-
break
140-
fi
141-
done
142-
if [ $current_groups -ne $TRUE ]; then
143-
NEED_RELOG=$TRUE
144-
fi
145-
146-
success
147-
fi
148-
149-
echo "Adding $user to the $GROUP group.."
150-
NEED_RELOG=$TRUE
151-
152-
declare -a tasks=("add/create a group named $GROUP ($ groupadd -f $GROUP)" "add your user account to the group named $GROUP ($ usermod -a -G $GROUP $user)")
153-
154-
print_tasks_if_needed()
155-
{
156-
ret=$?
157-
if [ $ret -ne 0 ]; then
158-
echo
159-
echo "It looks like this installer failed with only a few task(s) left to complete."
160-
echo "LabJack developed this installer on Ubuntu/Debian Linux, so if you are running"
161-
echo "Ubuntu/Debian, please contact LabJack. However, if you are running a"
162-
echo "different distribution of Linux, it is likely that your distribution varies"
163-
echo "enough to make these last task(s) fail."
164-
echo
165-
echo "You can search the internet for how to complete the following task(s) on your"
166-
echo "distribution of Linux:"
167-
for n in "${tasks[@]}"; do
168-
echo " - $n"
169-
done
170-
echo
171-
echo "Where the Ubuntu/Debian commands for the tasks are in parenthesis."
172-
echo
173-
echo "Once these tasks are complete, your installation of Exodriver will be complete."
174-
echo
175-
echo "If you are on a common distribution of Linux or if you are not sure how to"
176-
echo "complete the above task(s), please contact LabJack support. If your"
177-
echo "distribution of Linux is old, consider upgrading to see if that solves the"
178-
echo "problem."
179-
echo
180-
echo "LabJack support: [email protected]"
181-
echo
182-
echo "Please also follow any following instructions."
183-
echo
184-
IS_SUCCESS=$FALSE
185-
success
186-
fi
187-
}
188-
189-
groupadd -f $GROUP
190-
print_tasks_if_needed
191-
unset tasks[0]
192-
193-
usermod -a -G $GROUP $user
194-
print_tasks_if_needed
195-
unset tasks[1]
196-
197118
success

0 commit comments

Comments
 (0)