当前位置: 技术问答>linux和unix
500分求一Linux下C语言程序!(分数还可以加倍,只要实现功能)
来源: 互联网 发布时间:2015-07-29
本文导语: 题目要求如下,要求有注释: Students are required to design, implement and test a program which will run within the L150 Linux facility or similar. This program may either be written using a combination of modules written using 'C' and...
题目要求如下,要求有注释:
Students are required to design, implement and test a program which will run within the L150 Linux facility or similar. This program may either be written using a combination of modules written using 'C' and Bash shell script supported by standard Posix command utilities such as sed(1), awk(1), grep(1) etc or alternatively entirely in Perl.
This program is required to modify system data files in a suitable manner for creating or removing a user login account on the operating system. The end user of this program must be able to use it to add and remove entries relevant for a specified user.
As administrator access to TIC supported Linux facilities is not feasible, the program to be designed and implemented by the student must support command line parameters suitable for specifying alternative paths for copies of the relevant system files which would need to be updated if this program were to be run by the root user.
The program must be able to add and remove records to and from copies of files with the same format and organisation as the /etc/passwd and /etc/group files as documented in the system manual pages: passwd(5), shadow(5) and group(5). Use of the system call:crypt(2) is required for the creation of one-way hashed passwords from plain-text passwords. The program should test if it is run as user: root and if so, create directory: /home/new_userid with appropriate user and group ownership, where new_userid is the new user login to be created.
要求学生们设计、实现并测试一个能够在L150 Linux或类似设备上运行的程序。这个程序或者可以用一个以"C"语言和Posix标准命令功能所支持的Bash shell脚本如sed(1), awk(1), grep(1)等编写的联合模块来设计编写,或者可以完全用Perl来完成。
要求该程序能通过某种合适的方式修改系统数据文件,以创建或删除一个用户在操作系统上的登录帐号。这个程序的最终用户应当能够用它(这个程序)为指定用户添加并删除相关的登录信息。
作为管理员有权使用被Linux设备支持的TIC(技术情报中心)是不可行的,如果这个由学生设计实现的程序被超级(根目录)用户运行,那么相关的系统文件的复件的路径就需要被更新,而该设计的程序就必须要支持适合指定上面更新路径的命令行参数。
这个程序要能够向文件复件添加记录以及能从文件复件移除记录,这些文件同/etc/passwd、/etc/group文件具有相同的数据格式和结构,这些格式和结构在系统手册页中都有记录:(请参考)passwd(5), shadow(5) and group(5)。系统调用的使用:crypt(2)要求用在从明文口令到单链哈希口令的创建中。如果被超级用户运行,该程序应该检测目录,并且使用适当的用户和组身份创建目录:/home/new_userid,new_userid即新用户登录的用户ID就会在该目录下被创建。
Students are required to design, implement and test a program which will run within the L150 Linux facility or similar. This program may either be written using a combination of modules written using 'C' and Bash shell script supported by standard Posix command utilities such as sed(1), awk(1), grep(1) etc or alternatively entirely in Perl.
This program is required to modify system data files in a suitable manner for creating or removing a user login account on the operating system. The end user of this program must be able to use it to add and remove entries relevant for a specified user.
As administrator access to TIC supported Linux facilities is not feasible, the program to be designed and implemented by the student must support command line parameters suitable for specifying alternative paths for copies of the relevant system files which would need to be updated if this program were to be run by the root user.
The program must be able to add and remove records to and from copies of files with the same format and organisation as the /etc/passwd and /etc/group files as documented in the system manual pages: passwd(5), shadow(5) and group(5). Use of the system call:crypt(2) is required for the creation of one-way hashed passwords from plain-text passwords. The program should test if it is run as user: root and if so, create directory: /home/new_userid with appropriate user and group ownership, where new_userid is the new user login to be created.
要求学生们设计、实现并测试一个能够在L150 Linux或类似设备上运行的程序。这个程序或者可以用一个以"C"语言和Posix标准命令功能所支持的Bash shell脚本如sed(1), awk(1), grep(1)等编写的联合模块来设计编写,或者可以完全用Perl来完成。
要求该程序能通过某种合适的方式修改系统数据文件,以创建或删除一个用户在操作系统上的登录帐号。这个程序的最终用户应当能够用它(这个程序)为指定用户添加并删除相关的登录信息。
作为管理员有权使用被Linux设备支持的TIC(技术情报中心)是不可行的,如果这个由学生设计实现的程序被超级(根目录)用户运行,那么相关的系统文件的复件的路径就需要被更新,而该设计的程序就必须要支持适合指定上面更新路径的命令行参数。
这个程序要能够向文件复件添加记录以及能从文件复件移除记录,这些文件同/etc/passwd、/etc/group文件具有相同的数据格式和结构,这些格式和结构在系统手册页中都有记录:(请参考)passwd(5), shadow(5) and group(5)。系统调用的使用:crypt(2)要求用在从明文口令到单链哈希口令的创建中。如果被超级用户运行,该程序应该检测目录,并且使用适当的用户和组身份创建目录:/home/new_userid,new_userid即新用户登录的用户ID就会在该目录下被创建。
|
up
|
用shell 可以实现,不过你的目标不明确。
增加: echo 'xxx' >> file
刪除: cat file | sed 's/xxxx//' > tmp; mv tmp file
再判断是否为系統管理員操作:..........
增加: echo 'xxx' >> file
刪除: cat file | sed 's/xxxx//' > tmp; mv tmp file
再判断是否为系統管理員操作:..........
|
呵呵,大概什么时候要?
|
这个题目不难,就是掌握了上面提到的几个函数就可以模拟一套unix的验证文件了。呵呵,怎么看都象作业题,自己动动手呀。
|
use system command
there is an example in "Learning Linux Kernel by Practice" page 31
浙江大学出版社
there is an example in "Learning Linux Kernel by Practice" page 31
浙江大学出版社
|
有难度