Ejemplo n.º 1
0
//tunnel process function block<input type="checkbox" n<input type="checkbox" name="" value="">ame="" value="">
//success :1 ; fail :0;
int setup_tunnel(struct vty *vty,char *src_ip,char *dst_ip,int lsp_id){
	printf("Debug msg(setup_tunnel): src_ip :%s\t dst_ip:%s\t lsp_id :%d\n",src_ip,dst_ip,lsp_id);
	char buf[255];
	tunnel_entry *tunnel=tunnel_get();
	if(!tunnel){//no tunnel entry to add first new tunnel_entry
		tunnel=tunnel_new(); 	
		if(add_new_tunnel_entry(inet_addr(dst_ip),tunnel)){	
  	  vty_out(vty,"Create a new tunnel fail. %s",VTY_NEWLINE);
  	  return 0;
  	}else{//create new tunnel  	
 					connect_daemon(VTYSH_INDEX_RSVPD);	
 					RSVP_New_Command cmd;
 					cmd=SEND_PATH_MSG;
 					sprintf(buf,"rsvp_cmd_type %d arg0 %s arg1 %s arg2 %d arg3 %s\n",cmd,src_ip,dst_ip,lsp_id,"NULL");
 					vtysh_client_execute(&vtysh_client[VTYSH_INDEX_RSVPD], buf, stdout);
 					exit_daemon(VTYSH_INDEX_RSVPD);
 					return 1;
  	}
	}else{//have one or more tunnel_entry to check remote_ip address is used or unused;
		 //need to check remote_ip is used or unused
		  printf("Tunnel is exit then create new tunnel entry.\n");
   	 	if(qurray_tunnel_entry(inet_addr(dst_ip),tunnel)){
   	  	tunnel=tunnel_new_more(tunnel);
   	  	if(add_new_tunnel_entry(inet_addr(dst_ip),tunnel)){
   	  		vty_out(vty,"Create a new tunnel fail. %s",VTY_NEWLINE);
  	  		return 0;
   			}else{
	 			//need to check rsvp daemon is setup tunnel or not; those codes doesn't ready.
					RSVP_New_Command cmd;
 					cmd=SEND_PATH_MSG;
 					connect_daemon(VTYSH_INDEX_RSVPD);
 					sprintf(buf,"rsvp_cmd_type %d arg0 %s arg1 %s arg2 %d arg3 %s\n",cmd,src_ip,dst_ip,lsp_id,"NULL");
 					vtysh_client_execute(&vtysh_client[VTYSH_INDEX_RSVPD], buf, stdout);
 					exit_daemon(VTYSH_INDEX_RSVPD);
 					return 1;
	 			}
	 			//tunnel->out_state = PROCESSING;
				//return CMD_WARNING;
		 }else{
				vty_out(vty,"The remote_ip is already exit.\n");
				return 0;
			}
	}
}
Ejemplo n.º 2
0
int su_main(int argc, char *argv[]) {
    int ppid = getppid();
	if ((geteuid() != AID_ROOT && getuid() != AID_ROOT) ||
			(get_api_version() >= 18 && getuid() == AID_SHELL) ||
			get_api_version() >= 19) {
		// attempt to connect to daemon...
		LOGD("starting daemon client %d %d", getuid(), geteuid());
		return connect_daemon(argc, argv, ppid);
	} else {
		return su_main_nodaemon(argc, argv);
	}

}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
    // start up in daemon mode if prompted
    if (argc == 2 && strcmp(argv[1], "--daemon") == 0) {
        return run_daemon();
    }

    // attempt to use the daemon client if not root,
    // or this is api 18 and adb shell (/data is not readable even as root)
    if (is_api_18()) {
        if (geteuid() != AID_ROOT || getuid() != AID_ROOT) {
            // attempt to connect to daemon...
            LOGD("starting daemon client %d %d", getuid(), geteuid());
            return connect_daemon(argc, argv);
        }
    }

    LOGD("skipping daemon client %d %d", getuid(), geteuid());

    // Sanitize all secure environment variables (from linker_environ.c in AOSP linker).
    /* The same list than GLibc at this point */
    static const char* const unsec_vars[] = {
        "GCONV_PATH",
        "GETCONF_DIR",
        "HOSTALIASES",
        "LD_AUDIT",
        "LD_DEBUG",
        "LD_DEBUG_OUTPUT",
        "LD_DYNAMIC_WEAK",
        "LD_LIBRARY_PATH",
        "LD_ORIGIN_PATH",
        "LD_PRELOAD",
        "LD_PROFILE",
        "LD_SHOW_AUXV",
        "LD_USE_LOAD_BIAS",
        "LOCALDOMAIN",
        "LOCPATH",
        "MALLOC_TRACE",
        "MALLOC_CHECK_",
        "NIS_PATH",
        "NLSPATH",
        "RESOLV_HOST_CONF",
        "RES_OPTIONS",
        "TMPDIR",
        "TZDIR",
        "LD_AOUT_LIBRARY_PATH",
        "LD_AOUT_PRELOAD",
        // not listed in linker, used due to system() call
        "IFS",
    };
    const char* const* cp   = unsec_vars;
    const char* const* endp = cp + sizeof(unsec_vars)/sizeof(unsec_vars[0]);
    while (cp < endp) {
        unsetenv(*cp);
        cp++;
    }

    /*
     * set LD_LIBRARY_PATH if the linker has wiped out it due to we're suid.
     * This occurs on Android 4.0+
     */
    setenv("LD_LIBRARY_PATH", "/vendor/lib:/system/lib", 0);

    LOGD("su invoked.");

    struct su_context ctx = {
        .from = {
            .pid = -1,
            .uid = 0,
            .bin = "",
            .args = "",
            .name = "",
        },
        .to = {
            .uid = AID_ROOT,
            .login = 0,
            .keepenv = 0,
            .shell = NULL,
            .command = NULL,
            .argv = argv,
            .argc = argc,
            .optind = 0,
            .name = "",
        },
        .user = {