T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

Linux���ļ�������Ȩ��SUID,SGID,SBIT����

�� ���� ����ʱ�䣺2010-05-17 | ���壺�� �� С��
[����]�ļ�������Ȩ��SGID, SUID..SBIT ���Ҷ�֪���ļ���Ŀ¼��Ȩ�������������.�ɶ�(r)..��д(w)..��ִ��(x)..���ǵļ����ֱ���4..2..1..������ʱҲ�ᷢ����Щ�ļ���������Ȩ���ϴ���һ��s�ı�־λ.Ŀ¼����������Ҳ��...

�ļ�������Ȩ��SGID, SUID..SBIT

        ���Ҷ�֪���ļ���Ŀ¼��Ȩ�������������.�ɶ�(r)..��д(w)..��ִ��(x)..���ǵļ����ֱ���4..2..1..������ʱҲ�ᷢ����Щ�ļ���������Ȩ���ϴ���һ��s�ı�־λ.Ŀ¼����������Ҳ����s��־λ.�ܶ��˲���������Ϊʲô....�������Ǿ�������һ��...
         #ls -l  /usr/bin/passwd
         -rwsr-xr-x 1 root root 19876 Jul 17  2006 /usr/bin/passwd
         �����ļ�����������x��־λ�ϱ�����s,��ʱ��Ϊset uid ..��д����suid..��ʵ�����ļ�����Ҳû�������ĺ���..������s��־λ������һЩ�ű���ʱ,������������...�ȷ�˵��������һ���ű���Ϊsum.sh.�����ű���Ȩ������:
        -rwsrwxr-x 1 root root   117 Feb  6 20:46 sum.sh
         �����ű�����������������Ϊroot.���ǵ�Ȼ������root���û�������ִ����..���ǻ����Կ��������������ı�־λ���и�s..�������ж�ȡ��ִ�е�Ȩ��.�������������и���ͨ�û���Ϊredhat..�����л���redhat..ִ�д˽ű�..���������ǿ���ִ�гɹ���..��ʵ�����ǽ���root�û���������ִ����..������redhat..������suid������....
        ����������˵��SGID,����������SUID�������׾�֪����νSGID���ǽ���־s�ӵ�gid��x��־λ��..��Ϊset gid.����sgid..����ǿ��һ��SUID����һ�������ļ���.�ر���һЩ�ű���...SGID����Ŀ¼������...�ȷ�˵����root���ݴ���һ��Ŀ¼a.��������sgidȨ��
        #mkdir a
        #chmod   2757  a
        #ls  -l
          drwxr-srwx 2 root root  4096 Feb  6 21:09  a
        ��Ϊ���Ǹ�aĿ¼�����������е�Ȩ���ǿɶ�,��д,��ִ��...��������redhat�û��������л�������һ���ն�..����aĿ¼��,�����ڴ�Ŀ¼�д���һ��Ŀ¼b��һ���ļ�c
        [redhat@station18 a]$ mkdir b
        [redhat@station18 a]$ touch c
        [redhat@station18 a]$ ls -l
        drwxrwsr-x 2 redhat root 4096 Feb  6 21:20 b
        -rw-rw-r-- 1    redhat root    0 Feb  6 21:20 c
        ���ǿ��Կ���Ŀ¼b���ļ�c�������鶼Ϊroot......���㽫һ��aĿ¼��ΪsgidȨ��ʱ��,�����������ж�ȡ,ִ�к�д����Ȩ��ʱ,�����ڴ�Ŀ¼�д������κ��ļ���Ŀ¼�������鶼ΪaĿ¼��������..�������������Լ�...�����ᾭ�����õ�....��һ�����ҵ�ע��...�����κ�����aĿ¼�д����Ķ���.���˶�����ɾ��...��������������Ҫ������SBIT....
        SBIT ȫ��Sticky Bit.������ֻ��Ŀ¼��Ч,���ļ�ȴ����Ч��,�������þ��Ƿ�ֹ����ɾ���Է�������...���Ǿ�����˵��...
      1..����root�û���¼����һ��Ŀ¼��Ϊtest
       [root@station18 ~]# mkdir test
       [root@station18 ~]# chmod o+w test/
       [root@station18 ~]# ls -l
       drwxr-xrwx 2 root root  4096 Feb  6 21:30 test
      2..�����л���redhat�û���¼һ���ն�,����һ��Ŀ¼a..
       [redhat@station18 test]$ mkdir a
      3.�������л���xiaoming�û���¼һ���ն�,����һ��Ŀ¼b...
       [xiaoming@station18 test]$ mkdir b
       [xiaoming@station18 test]$ ls  -l
       drwxrwxr-x 2 redhat   redhat   4096 Feb  6 21:32 a
       drwxrwxr-x 2 xiaoming xiaoming 4096 Feb  6 21:31 b
       ���ǿ������κ��û������ݽ���testĿ¼���ֿ���ɾ��a��bĿ¼...������������...���˵�Ŀ¼����������ɾ��...��ʱ���Ǿ���Ҫ��testĿ¼����SBITȨ����...
       [root@station18 ~]# chmod  1757  test/
       [root@station18 ~]# ls -l
       drwxr-xrwt 4 root root  4096 Feb  6 21:42 test
       �������ñ����û���¼����testĿ¼����ɾ�������˵�������,ϵͳ����ʾrm: cannot remove directory `a': Operation not permitted..��˼����Ȩ�޲���....�Ǻ�...�������˾�û����....�Ҳ��Թ��ɹ���...
       ��������˵һ�¹���SUID SGID  SBITȨ�޵��趨...
        SUIDΪ4
        SGIDΪ2
        SBITΪ1
        ���������趨һЩ�ļ���Ŀ¼��Ȩ�������ܿ�����,,����������ϸ����...
        ���������и��ļ���file.��һ��Ŀ¼��test..file����Ȩ����644..test��Ȩ����755
        1..������������file����suidȨ�޵Ļ�ִ�д�����
        #chmod  4755  file
        2..������������testĿ¼����sgid�Ļ�ִ�д�����
        #chmod  2755   test/
        3.������������testĿ¼����sbitȨ�޵Ļ�ִ�д�����
        #chmod  1755   test/
        4..���ҿ��Կ��ó���s��t����ȡ��xȨ�޵�...
        5..����������test�߱�SUID��SGIDȨ��ִ�д�����
        #chmod   7666  file
        #ls  -l
         -rwSrwSrwT 1 root root     0 Feb  6 21:49 file
        ������S��T�ʹ�����..���߱�������ִ�е�Ȩ��...7666Ҳ����˵�û�,��,�Լ��������˶����߱�x��Ȩ��,����root.�κ����޸IJ��˴��ļ�...
        �����������ִ������ļ���һЩ Ȩ��....����Ҳ�����ñ��ķ���.�ȷ�˵..���Ǹ�file�ļ�����suidȨ��
        #chmod  u=rwxs,o=rx   file
        ��testĿ¼����SGIDȨ�޺�other�ɶ�ȡд��ִ��Ȩ��
        #chmod  g+s,o=wrx    test/
        ��testĿ¼����SBITȨ�޺�other�ɶ�ȡд��ִ��Ȩ��
        #chmod   o=rwxt   test/
 

ԭ�ģ�http://blog.chinaunix.net/u3/111913/showart_2182986.html

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:6.97ms QueryTime:7