Skip to content

Commit

Permalink
Added udev and perms rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lelegard committed Jun 27, 2018
1 parent b789060 commit 4c88457
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions linux-drivers/60-hides.perms
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# security settings for hides devices
<hides>=/dev/usb-it950x*
<console> 0600 <hides> 0660 root.video
2 changes: 2 additions & 0 deletions linux-drivers/60-hides.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# udev rules for hides devices
KERNEL=="usb-it950x*", GROUP="video", MODE="0660"
9 changes: 6 additions & 3 deletions linux-drivers/build-dkms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ sed -e "s/{{VERSION}}/$VERSION/g" "$ROOTDIR/config/dkms.conf.template" >"$DKMS_D
sed -e "s/{{VERSION}}/$VERSION/g" "$ROOTDIR/config/Makefile.template" >"$DKMS_DIR/Makefile"
cp -r "$ROOTDIR/it950x_driver" "$DKMS_DIR"
make -C "$DKMS_DIR" --no-print-directory --silent clean
find "$DKMS_DIR" -type f -print0 | xargs -0 chmod 644
find "$DKMS_DIR" -type d -print0 | xargs -0 chmod 755
cp "$ROOTDIR/60-hides.rules" "$ROOTDIR/60-hides.perms" "$SRCDIR"
find "$SRCDIR" -type f -print0 | xargs -0 chmod 644
find "$SRCDIR" -type d -print0 | xargs -0 chmod 755

# Build a source tarball for the hides-dkms package.
mkdir -p "$PKGDIR" || cleanexit 1
Expand Down Expand Up @@ -105,12 +106,14 @@ if $DEB_DISTRO; then
rm -rf "$DEBDIR"
# Build file structure of the package.
mkdir -p -m 0755 "$DEBDIR/DEBIAN" "$DEBDIR/usr/src"
mkdir -p -m 0755 "$DEBDIR/DEBIAN" "$DEBDIR/usr/src" "$DEBDIR/etc/udev/rules.d" "$DEBDIR/etc/security/console.perms.d"
for f in control postinst prerm; do
sed -e "s/{{VERSION}}/$VERSION/g" "$ROOTDIR/config/$f.template" >"$DEBDIR/DEBIAN/$f"
done
chmod 755 "$DEBDIR/DEBIAN/postinst" "$DEBDIR/DEBIAN/prerm"
cp -rp "$SRCDIR/hides-$VERSION" "$DEBDIR/usr/src"
install -m 644 "$SRCDIR/60-hides.rules" "$DEBDIR/etc/udev/rules.d"
install -m 644 "$SRCDIR/60-hides.perms" "$DEBDIR/etc/security/console.perms.d"
# Build the binary package
dpkg --build "$DEBDIR" "$PKGDIR"
Expand Down
6 changes: 5 additions & 1 deletion linux-drivers/config/hides-dkms.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ by ITE Technologies Inc. for IT950x chipsets.

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/src
mkdir -p $RPM_BUILD_ROOT/usr/src $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d $RPM_BUILD_ROOT%{_sysconfdir}/security/console.perms.d
cp -r hides-%{version} $RPM_BUILD_ROOT/usr/src
install -m 644 60-hides.rules $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d
install -m 644 60-hides.perms $RPM_BUILD_ROOT%{_sysconfdir}/security/console.perms.d

%post
[[ $(/usr/sbin/dkms status | grep hides | grep "%{version}" | wc -l) -eq 0 ]] && /usr/sbin/dkms add -m hides -v "%{version}"
Expand All @@ -45,3 +47,5 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/usr/src/hides-%{version}
%{_sysconfdir}/udev/rules.d/60-hides.rules
%{_sysconfdir}/security/console.perms.d/60-hides.perms
3 changes: 2 additions & 1 deletion linux-drivers/config/postinst.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

if [[ "$1" = "configure" ]]; then
# Fix file permissions and ownership.
chown -R root:root /usr/src/hides-{{VERSION}}
chown -R root:root /usr/src/hides-{{VERSION}} /etc/udev/rules.d/60-hides.rules /etc/security/console.perms.d/60-hides.perms
find /usr/src/hides-{{VERSION}} -type f -print0 | xargs -0 chmod 644
find /usr/src/hides-{{VERSION}} -type d -print0 | xargs -0 chmod 755
chmod 644 /etc/udev/rules.d/60-hides.rules /etc/security/console.perms.d/60-hides.perms

# Build the initial version of the driver.
[[ $(/usr/sbin/dkms status | grep hides | grep "{{VERSION}}" | wc -l) -eq 0 ]] && /usr/sbin/dkms add -m hides -v "{{VERSION}}"
Expand Down

0 comments on commit 4c88457

Please sign in to comment.