【正文】
然后再 把從 組添加組界面得到的數(shù)據(jù)發(fā)送到服務程序。 刷新按鈕所觸發(fā)的事件是: 調(diào)用 UserScan()函數(shù)。 刪除按鈕后 被按下了后 ,就調(diào)用 User_Del()函數(shù)。其界面如圖 14所示 。 } ? 主界面 當用戶端和服務器端連接成功后,就進入主窗體流程了,在主窗體建立前要接收一些從 服務程序發(fā)送過來的數(shù)據(jù),然后把這些數(shù)據(jù)存放到一些臨時文件里面,等 待 具體創(chuàng)建窗體的時候 調(diào)用 這些數(shù)據(jù)來初始化界面。 char *text = NULL。 } 上面函數(shù)大概反映了 GTK 變成中常用的構(gòu)件和函數(shù)。 gtk_signal_connect_object(GTK_OBJECT(exitButt), clicked,GTK_SI GNAL_FUNC(Destroy), GTK_OBJECT(mainWin))。 gtk_table_attach_defaults((GtkTable*)table,textbox,1,2,0,1)。 textbox = gtk_entry_new()。 int level。 退出系統(tǒng)啟動服務管理到圖 3 的recv() 服務停止操作 字符 Net_DNS_Config () recv() restart refresh saveconfig start 服務啟動操作 服務重啟操作 發(fā)送配置文件內(nèi)容 修改配置文件的操作 stop 圖 10 連接界面的流程圖 程 序從 main()進入以后就調(diào)用 gtk_init()函數(shù)。把用戶操作后的結(jié)果通過 SOCK 來傳達給服 務器程序。 其流程如圖 9 所示 。 刪除 domain 操作先接收客戶程序發(fā)送的數(shù)據(jù) (要刪除的 domain,和 zone),然后判斷 /var/named/chroot/etc/ 中是否有這個 zone 存在, 如果沒有就發(fā)送“ zone name is not exist”到客戶程序, 如果有 就得到其數(shù)據(jù)文件名字, 然后在數(shù)據(jù)文件中查看是否有 domain 存在, 如果沒有 就發(fā)送“ Domain name is not exist”到客戶程序, 如果有 就刪除 domain 部分 , 然后發(fā)送“ Domain del succseed”到客戶程序。 (4) DNS 管理操作 圖 3的程序流程到 Net_DNS_Config()函數(shù) 就 進入 DNS 功能模塊了 。 其流程如圖 6 所示 。再 次打開文件 /etc/group,把 temp 的數(shù)據(jù)都寫到文件中,關閉文件,這樣就完成組的刪除操作。重新以寫文件的操作打開文件 /etc/passwd,然后把 二 維數(shù)組 (temp)中的數(shù)據(jù) 以流的形式再 寫入到文件 /etc/passwd 中 , 這樣就完成了修改用戶的操作 當 進入 瀏覽用戶的流程后,打開 /etc/passwd 文件,把文件的數(shù)據(jù)讀取到buff 中,再 關閉文件,把 buff 的數(shù)據(jù)發(fā)送的到客戶程序 , 讓客戶程序顯示當前的用戶信息。再 以寫的形式打開文件,然后把上面 二 維數(shù)組 (temp)的內(nèi)容 寫到文件中,最后再 把變量 (str)寫到文件中 , 這樣 就實現(xiàn)了用戶的添加 。 處理 請求 否 是 初始化數(shù)據(jù) 退出 連 接不成功 main() 連接界面 輸入服務器 IP 建立連接( TCP3 次握手) 用戶主界面 用戶操作 等待連接 TCP 接口 退出 TCP 接口 結(jié)束 結(jié)束 連接成功 圖 3 服務程序的流程圖 功能模塊 (1) 系統(tǒng) 用戶 管理 操作 和客戶程序建立 了 連接,并且收到了 user 字符串后 , 服務程序 進入系統(tǒng) 用戶 管理 操作模塊 , 接著 接收 客戶程序發(fā)送過來的數(shù)據(jù) (字符串 ),通過數(shù)據(jù)來判斷 是對用戶 的添加、刪除、瀏覽或 修改操作 。 5 程序設計和流程圖 設計思路 本課題是采用 C/S 模式 。 區(qū)分這兩個東西是很重要的。 (4) listen 函數(shù) listen 函數(shù)只能 由 TCP 服務器調(diào)用,他完成兩 件事 : 一是 當 socket 函數(shù)創(chuàng)建一個套接口 時 它是一個主動的套接口,該函數(shù)就是把它轉(zhuǎn)換成一個被動的套接口 二是 該函數(shù)規(guī)定了為相應套接口排隊的最大的連接個數(shù)。 這個 函數(shù)通常是在客戶 程序 中 使用 。 4 基本的套接口編程 概述 讓同一網(wǎng)絡的不同計算機的進程能夠相互通信,首先要確定這些程序如何進行通信 。 父進程和子進程間的區(qū)別就是進程的 pid 不同,其他的都一樣 : pid_t result = fork(void) 該函數(shù)比較特殊,它返回兩次 函數(shù)值 ,一次返回值是 向 父進程返回 子進程的 PID。 進程不 需要 再 對文件進行讀寫操作時,就要關系文件 打開的文件。 ? 在 Linux 中打開一個文件可以通過系統(tǒng)調(diào)用 open()函數(shù)來實現(xiàn) : int fd = open(char *name,int how)。 回調(diào)函數(shù)用下面的形式連接到信號: gtk_signal_connect(GTK_OBJECT( clist), select_row, GTK_SIGNAL_FUNC(select_row_callback), NULL)。 gint gtk_clist_append( GtkCList *clist,gchar *text[] )。 ( 7) 分欄列表構(gòu)件 GtkCList(分欄列表構(gòu)件 )是 GtkList(列表構(gòu)件 )的替代品,但它提供更多的特性。要說明大量的相關 信息,同時把它們分別顯示時,使用這種構(gòu)件是一個很好的方法。用以下函數(shù)創(chuàng)建新標簽構(gòu)件: GtkWidget *gtk_label_new(char *str )。 文本構(gòu)件有兩個主要用途:允許用戶編輯一段文本,或向用戶顯示多行文本。 ( 3) 按鈕 構(gòu)件 GtkButton(普通按鈕構(gòu)件 )是應用程序中使用最廣泛的構(gòu)件?!肮芾聿季帧币馕吨@些容器為它們?nèi)菁{的子構(gòu)件分配大小尺寸和位置。一種有一個相關聯(lián)的 GdkWindow窗口,另一種沒有。事件的回調(diào)函數(shù)與信號的回調(diào)函數(shù)在形式上略有不同: Void func(GtkWidget *widget, GdkEvent *event, gpointer callback_data )。一旦事件發(fā)生,比如鼠標器按鈕被按下,被按下 的構(gòu)件(按鈕)將引發(fā)適當?shù)男盘枴? 從根本上來說,主循環(huán)是由 glib 實現(xiàn)的。 本課題研究的意義 本課題是 為了給系統(tǒng)管理員提供一種 遠程管理 Linux 中某些 主要 服務的工具 軟件,完成 服務 配置管理 和查看一些重要的數(shù)據(jù)。 致 謝 .............................................................................................. 錯誤 !未定義書簽。 關鍵詞 : Linux; 系統(tǒng)服務 ; C/C++; GTK; 系統(tǒng)調(diào)用 ; Socket The Design and Implementation of a Remote Management Tool for Linux Abstract The operating system of Linux has bee one of the most popular operating systems nowadays. It provides many kinds of service. In order to configure and manage the service remotely, the tool of remote management of the operating system of Linux is needed. Webmin is a good tool of software based on the model of B/S. This design is implemented based on the model of C/S. The main functions of the system include addition, modification, deletion of users and groups of Linux operating system and configuration and management of the service of application of the system, such as the DNS, FTP, Apache and the management of booting service. The remote management of service is implemented by modifying the files of configuration. The model of C/S is selected by this system. In the Client, the operating interface is made by the programming of GTK. In the Server, the functions of transferring of files of Linux operating system are used to write and read the data of the configuration files. The munication of Client and Server is implemented by the programming of Sock TCP. The testing demonstrates that the system has reached the prospective goal. But lots of improvements should be made and the problems of security should be considered more. After being modified and perfected, the system can be used to manage the system remotely. Key words: Linux。 該工具主要功能 實現(xiàn) 對 Linux 系統(tǒng) 用戶和組的添加、修改和刪除 ; 對系統(tǒng) 應用 服務 (如 :DNS、 FTP、 Apache、 系統(tǒng)啟動服務管理 )進行 管理和配置 , 這些服務的 遠程 配置主要是通過 修改 服務配置 文本文件來實現(xiàn)的 。Socket 目 錄 論文總頁數(shù): 33 頁 1 引言 ......................................................................................................................... 1 課題背景 .......................................................................................................... 1 國內(nèi)外研究現(xiàn)狀 ............................................................................................... 1 本課題研究的意義 ............................................................................................ 1 本課題的研究方法 ............................................................................................ 1 2 GTK 編程 ................................................................................................................. 1 GTK簡介 .......................................................................................................... 1 常用的 GTK構(gòu)件 ............................................................................................... 3 3 LINUX系統(tǒng)調(diào)用 ..............................