/* manages the /etc/security/time.conf file */ /* this time configurador is another lame one.. must be improved later */ #include #include #include #include "pamconf.h" #include "pamconf.m" #include "pamconf_tools.h" #include "fviews.h" void line_properties_time(int which_line, VIEWITEMS &given_vitems) { DIALOG my_dialog; MENU_STATUS my_button=MENU_NULL; int my_selection=0; SSTRING title_text; SSTRING *current_line; SSTRING tservices, ttty, tusers, ttimes; current_line=&(given_vitems.getitem(which_line)->line); title_text.setfromf(MSG_U(T_TIMENTRYNFORTIMEDEF, "Entry #%d for time definitions"), which_line+1); /* load vars */ gimme_word_from_string_bchar(current_line->get(), tservices, 0, ';'); gimme_word_from_string_bchar(current_line->get(), ttty, 1, ';'); gimme_word_from_string_bchar(current_line->get(), tusers, 2, ';'); gimme_word_from_string_bchar(current_line->get(), ttimes, 3, ';'); /* builds gui */ my_dialog.newf_str(MSG_U(F_TIMSERVICES, "Service:"), tservices); my_dialog.newf_str(MSG_U(F_TIMTTYS, "Terminals:"), ttty); my_dialog.newf_str(MSG_U(F_TIMUSERS, "Users:"), tusers); my_dialog.newf_str(MSG_U(F_TIMTIMES, "Times:"), ttimes); while(1){ /* opens dialog.. */ my_selection=0; my_button=my_dialog.editmenu(title_text.get(), "", hf_pam_time, my_selection, MENUBUT_QUIT|MENUBUT_DEL|MENUBUT_ACCEPT); switch(my_button){ case MENU_QUIT: case MENU_ESCAPE: return; case MENU_DEL: if(confirm_yesno_window(MSG_U(T_TIMENTRYREMOV, "Entry removal"), MSG_U(I_TIMENTRYREMOV, "Do you really want\nto remove this definition?"))){ given_vitems.remove_del(which_line); given_vitems.write(cf_time, NULL); return; } break; case MENU_ACCEPT: current_line->setfromf("%s;%s;%s;%s", tservices.get(), ttty.get(), tusers.get(), ttimes.get()); /* writes to file */ given_vitems.write(cf_time, NULL); return; break; default: break; } } } void time_window(void) { DIALOG_RECORDS my_dialog; MENU_STATUS my_button=MENU_NULL; int my_selection=0; VIEWITEMS_PARSER pre_my_vitems; while(1){ VIEWITEMS my_vitems(pre_my_vitems); my_vitems.read(cf_time); // load file data my_dialog.remove_all(); // cleans window my_dialog.newf_head("", MSG_U(F_TIMSTUT, "services\tTTYs\tusers\ttimes")); dump_viewitems_to_list(my_dialog, my_vitems, 4, ';'); /* opens dialog.. */ my_selection=0; my_button=my_dialog.editmenu(MSG_U(T_TIMTIME, "Time (pam_time.so)"), MSG_U(I_TIMTIME, "These settings defines the times\nwhen certain users are permitted to log in."), hf_list_edit, my_selection, MENUBUT_QUIT|MENUBUT_ADD); switch(my_button){ case MENU_QUIT: case MENU_ESCAPE: return; case MENU_ADD: my_vitems.add(new VIEWITEM(MSG_U(X_TIM_SAMPLE, "some_services;a_TTY;couple_of_users;!Al0000-2400"))); line_properties_time(my_vitems.getnb()-1, my_vitems); break; default: line_properties_time(my_selection, my_vitems); break; } } }