[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: device access (specifically ttySx)



Paul Miller wrote:
> 
> George Bonser wrote:
> >
> > Onw way is to have those ports owned by certain groups.  You then
> > place
> > the users that you want to allow access into the group for that port.
> >
> how do you do that?  mc won't make any changes.. should I just use
> chown/grp/mod?

Try the attached (if you have perl on your system).
> 
> Paul
> 
> --
> TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
> debian-user-request@lists.debian.org .
> Trouble?  e-mail to templin@bucknell.edu .

-- 
-----------------------------------------
Ralph Winslow		      rjw@nac.net
The IQ of the group is that of the member
whose IQ is lowest  divided by the number
of members.
#!/usr/bin/perl
# chuser - move selected users to a selected new group
# rjw - 19970726

if($#ARGV < 0 || $ARGV[0] =~ /^-[hH?]/)
    { die "chuser: Usage: chuser <new_group>\n"; };
if($<) { die "chuser: You must be root to run chuser\n"; };
$PWD = '/etc/passwd';
$PWDnew = $PWD.$$;
$GRP = '/etc/group';
$GRPnew = $GRP.$$;
foreach $grp (@ARGV)
    { open(GRP,$GRP) || die "chuser: can't rred $GRP: $!\n";
    open(GRPnew,'>'.$GRPnew) || die "chuser: can't write $GRPnew: $!\n";
    foreach $curgrp (@groups = <GRP>)
	{ if($Debug) { print $curgrp; };
	print GRPnew $curgrp;
	($grid,$x,$grno,$grname) = split(/:/,$curgrp);
	if(/^$grp:/) { $sawGRP++; $grpnum = $grno; }
	else { $grpno{$grno} = $grid; };
	}; close(GRP);
    if($sawGRP) { close(GRPnew); unlink($GRPnew); }
    else { unlink($GRP) || die "chuser: unlink $GRP: $!\n";
	for($grpidx = 10; $grpno{$grpidx}; ) { $grpidx += 10; };
	print GRPnew "$grp:$grpidx:$grp Group\n";
	close(GRPnew) || die "chuser: closeing GRPnew $GRPnew: $!\n";
	$grpnum = $grpidx;
	link($GRPnew,$GRP) || die "chuser: linking $GRP $GRPnew: $!\n";
	unlink($GRPnew) || die "chuser: unlinking $GRPnew: $!\n";
	};
    open(PWD,$PWD) || die "chuser: can't read $PWD: $!\n";
    open(PWDnew,'>'.$PWDnew) || die "chuser: can't write $PWDnew: $!\n";
    foreach $usr (@users = <PWD>)
	{ if($usr =~ /^root:/) { print PWDnew $usr; next; };
	if($usr =~ /^uucp:/) { print PWDnew $usr; next; };
	($id,$x,$uidx,$grps,$name,$home,$shl) = split(/:/,$usr);
	print $usr;
	print "$id in|out for $grp? "; chop($reply = <STDIN>);
	print PWDnew ($reply =~ /^[YyIi]/)?
	  "$id:x:$uidx:$grps,$grpidx:$name:$home:$shl\n":$usr;
	}; close(PWD) || die "Can't close $PWD: $!\n";
    unlink($PWD) || die "Can't unlink $PWD: $!\n";
    close(PWDnew) || die "Can't close $PWDnew: $!\n";
    link($PWDnew,$PWD) || die "Can't link $PWDnew to $PWD: $!\n";
    unlink($PWDnew) || die "Can't unlink $PWDnew: $!\n";
    };

Reply to: