ethtool 을 root 권한말고 일반 계정에서도사용하고싶은데여....

psg989의 이미지

어떻게해야될가요??ethool에서사용하는 dev 권한을 바꾸면될거같은데그게먼지모르겟어여 ㅠㅠ

chanik의 이미지

http://foralllinux.blogspot.kr/2013/04/set-setuid-setgid-and-sticky-bit-in.html

해당 장치파일의 권한을 바꾸는 대신,
ethtool 실행파일 권한중 SUID 비트를 켜고 쓰는 방법이 있습니다.

실행파일 사본을 만들어 SUID 비트를 켜려면 아래와 같이 하면 됩니다.

$ cp `which ethtool` .
$ sudo chown root ./ethtool
$ sudo chmod u+s ./ethtool
$ ls -al ./ethtool
-rwsr-xr-x 2 root test01 117824  4월  3  2010 ./ethtool

이제 root가 아닌 사용자가 ./ethtool 을 실행해도 파일소유자인 root 권한으로 동작하게 됩니다.
(참고: 원본 ethtool 실행파일은 여전히 실행하는 사용자의 권한으로 동작합니다)

$ ./ethtool -i eth0
NIC statistics:
     tx_packets: 97956446
     rx_packets: 85218830
     tx_errors: 0
     rx_errors: 0
     rx_missed: 0
     align_errors: 0
     tx_single_collisions: 0
     tx_multi_collisions: 0
     unicast: 76553800
     broadcast: 8425826
     multicast: 335585
     tx_aborted: 0
     tx_underrun: 0

김정균의 이미지

SUID를 사용하는 것 보다는 sudo로 권한을 주는 것을 권장합니다.

USERID  ALL=(ALL) NOPASSWD: /usr/bin/ethtool

과 같이 sudoers file에 지정할 수 있습니다.

chanik의 이미지

sudo에 이렇게 세세하게 권한을 제어할 수 있는 기능이 있었네요.

그런데, 제가 쓰는 CentOS-5.10에서는 아래와 같이 해 봐도 원하는대로 동작하지는 않았습니다.
sudoers 파일의 제일 마지막에 추가했고, visudo 명령을 통해서 했습니다.
/sbin 에 들어있는 파일은 안 되는 것인가 싶어서 다른 디렉토리에 사본을 만들어서 해봐도 마찬가지고요.
인터넷 찾아보니 잘 된다는 경우가 많던데, 제 PC는 뭐가 문제인지 모르겠습니다.

test01     ALL=(ALL)   NOPASSWD: /sbin/ethtool
test01     ALL=NOPASSWD: /sbin/ethtool
goforit의 이미지

Posix Capability를 사용하는 것 어떨까요?
Posix Capability 사용하는 것은 배움 차원에서 Root의 권한을 쪼개어 생각하는 데 도움이 됩니다.

ethtool에 직접 setcap를 적용 안 해보았지만, 이렇게 하면 될 것 같습니다.
$ setcap cap_net_admin+ep /usr/bin/ethtool

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.