On the Internet, we can see some solutions for directly adding system users through php. These methods are all saved in the script system's Superuser password? Security issues. The method provided here is to add a user to the mysql database through php at the front end, and set the password in the background through cron at intervals) to execute the program for adding a user. The system Superuser password is not recorded in the program, which ensures system security. The following is the background program for adding users. This program is just a rough demo program. The function is to add addornot = 0 users to the system for your reference only. The php program that adds user information to the database is omitted. The program passes
Adduserfromdb. pl #! /Usr/bin/perluse DBI; $ dbuser = "xxxx"; $ dbpasswd = "xxx"; $ db = "xxxx"; $ dbh = DBI-> connect ("DBI: mysql: $ db ", $ dbuser, $ dbpasswd); $ query =" select user, passwd from usertable where addornot = 0 "; $…… = $ dbh-> prepare ($ query); $ rv = $……-> execute or die "Can't execute the query: $…-> Errstr \ n "; while (@ row = $ th-> fetchrow_array) {# print" user = ". $ row [0]. "\ n"; # print "password = ". $ row [1]. "\ n"; @ saltchars = (.. z, .. z, 0 .. 9); srand (time | $); $ salt = $ saltchars [rand ($ # saltchars)]. $ saltchars [rand ($ # saltchars)]; # print "$ salt \ t $ row [1] \ n"; $ encrypt_passwd = crypt ($ row [1], $ salt); # print $ encrypt_passwd. "\ n"; $ add_exec = "/usr/sbin/useradd-p ". $ encrypt_passwd. "". $ row [0]; # Add parameters to useradd to control user groups, directories, logon status, shell, etc. # print $ add_exec. "\ n"; system ($ add_exec) ;}# 1; usertable: create table usertoadd (user tinytext not null, passwd tinytext not null, addornot tinyint (4) DEFAULT '0' not null ); |
Related Articles]
- Web-based installation of the SAV10.1 client configuration instructions
- Research on implementing Web-based Softswitch Configuration Management System
- Research on Web-based Softswitch Configuration Management System Based on J2EE Technology