示例#1
0
static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name)
{
	struct itemdef *ptr;


	/*
	 * Search into the table.
	 */

	for (ptr = def_table; NULL != ptr->name; ptr++) {
		if (strcmp (ptr->name, name) == 0) {
			return ptr;
		}
	}

	/*
	 * Item was never found.
	 */

	fprintf (stderr,
	         _("configuration error - unknown item '%s' (notify administrator)\n"),
	         name);
	SYSLOG ((LOG_CRIT, "unknown configuration item `%s'", name));
	return (struct itemdef *) NULL;
}
示例#2
0
void HardFault_Handler(void) {
    
    SYSLOG("HardFault_Handler\r\n");
    delay_ms(1000);
    NVIC_SystemReset();
    while (1);
}
示例#3
0
bool AlcEnabler::loadKexts() {
	if (that) return true;
	
	for (size_t i = 0; i < kextListSize; i++) {
		patcher.loadKinfo(&kextList[i]);
		if (patcher.getError() != KernelPatcher::Error::NoError) {
			SYSLOG("alc @ failed to load %s kext file", kextList[i].id);
			patcher.clearError();
			return false;
		}
		
		patcher.setupKextListening();
		
		if (patcher.getError() != KernelPatcher::Error::NoError) {
			SYSLOG("alc @ failed to setup kext hooking");
			patcher.clearError();
			return false;
		}
		
		auto handler = KernelPatcher::KextHandler::create(kextList[i].id, kextList[i].loadIndex,
		[](KernelPatcher::KextHandler *h) {
			if (h && that) {
				that->processKext(h->index, h->address, h->size);
			} else {
				SYSLOG("alc @ notification callback arrived at nowhere");
			}
		});
		
		if (!handler) {
			SYSLOG("alc @ failed to allocate KextHandler");
			return false;
		}
		
		patcher.waitOnKext(handler);
		
		if (patcher.getError() != KernelPatcher::Error::NoError) {
			SYSLOG("alc @ failed to wait on kext");
			patcher.clearError();
			KernelPatcher::KextHandler::deleter(handler);
			return false;
		}
	
	}
	
	that = this;
	return true;
}
示例#4
0
static int initializeDaemon(char *localDir, char *pluginDir, int portNum) {

  /*
   * Retrieve the directory of where this binary (magic-mirror.bin) resides so we can
   * find its dependent directories relative from the binary location.
   */
  if (!localDir) {
    char rootPath[PATH_MAX];
    readlink("/proc/self/exe", rootPath, PATH_MAX);

    //trim off the binary name from the binary path
    char *dirEnd = strrchr(rootPath, '/');
    if (dirEnd) *dirEnd = '\0';
    SYSLOG(LOG_INFO, "Main: Binary location: %s", rootPath);

    //change directory to where the binary is
    chdir(rootPath);
  } else {

    //otherwise, a user has specified a running directory
    chdir(localDir);
  }

  //first, initialize plugin list
  if (PluginList_Init()) {
    SYSLOG(LOG_ERR, "Main: Error initializing plugin list structure.");
    return -1;
  }

  //initialize all the plugins in the plugin directory
  if (DirectoryAction(pluginDir, &initPlugin, NULL)) {
    SYSLOG(LOG_ERR, "Main: Error initializing plugins.");
    return -1;
  }

  Display_Generate(portNum, COMS_DIR, CSS_DIR, JSLIBS_DIR, INDEX_FILE);
  API_Init(pluginDir);

  SYSLOG(LOG_INFO, "Main: creating socket");
  //initialize the websocket interface
  if (PluginSocket_Start(portNum)) {
    SYSLOG(LOG_ERR, "Main: Error starting socket server.");
    return -1;
  }

  return 0;
}
示例#5
0
bool PRODUCT_NAME::start(IOService *provider) {
	if (!IOService::start(provider)) {
		SYSLOG("init @ failed to start the parent");
		return false;
	}
	
	return true;
}
示例#6
0
/**
* @brief JNI_OnLoad
*/
jint JNI_OnLoad ( JavaVM* vm, void* reserved )
{
	JNIEnv* env = NULL;
	jint result = -1;

	SYSLOG("JNI_OnLoad");
	
	SYSLOG("Check JNI version");

	if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK)
	{
		return result;
	}
	
	jniRegisterNativeMethods( env, "com/mosync/internal/android/MoSyncThread", sMethods, numJavaMethods );
	return JNI_VERSION_1_4;
}
示例#7
0
文件: server.c 项目: hermixy/qtun
static void process_msg(client_t* client, msg_t* msg, vector_t* for_del, size_t idx)
{
    void* buffer = NULL;
    unsigned short len;
    int sys;
    size_t room_id;

    if (!check_msg(client, msg)) return;

    if (msg->syscontrol)
    {
        if (CHECK_SYS_OP(msg->sys, SYS_LOGIN, 1)) server_process_login(client, msg, idx, for_del);
        else
        {
            server_process_sys(client, msg);
            active_vector_up(&this.clients, idx);
        }
    }
    else if (msg->zone.clip)
    {
        if (!process_clip_msg(this.localfd, client, msg, &room_id)) goto end;
        active_vector_up(&this.clients, idx);
    }
    else if (parse_msg(msg, &sys, &buffer, &len, &room_id))
    {
        ssize_t written;
#ifdef WIN32
        WriteFile(this.localfd, buffer, len, &written, NULL);
#else
        written = write(this.localfd, buffer, len);
#endif
        SYSLOG(LOG_INFO, "write local length: %ld", written);
        active_vector_up(&this.clients, idx);
    }
    else
        SYSLOG(LOG_WARNING, "Parse message error");
end:
    if (buffer) pool_room_free(&this.pool, room_id);
    if (!this.use_udp)
    {
        client->status = (client->status & ~CLIENT_STATUS_WAITING_BODY) | CLIENT_STATUS_WAITING_HEADER;
        client->want = sizeof(msg_t);
        client->read = client->buffer;
        client->buffer_len = client->want;
    }
}
示例#8
0
bool PRODUCT_NAME::init(OSDictionary *dict) {
	if (!IOService::init(dict)) {
		SYSLOG("init @ failed to initalise the parent");
		return false;
	}
	
	return config.getBootArguments();
}
示例#9
0
void AlcEnabler::platformLoadCallback(uint32_t requestTag, kern_return_t result, const void *resourceData, uint32_t resourceDataLength, void *context) {
	if (that && that->orgPlatformLoadCallback) {
		that->updateResource(Resource::Platform, resourceData, resourceDataLength);
		that->orgPlatformLoadCallback(requestTag, result, resourceData, resourceDataLength, context);
	} else {
		SYSLOG("alc @ platform callback arrived at nowhere");
	}
}
示例#10
0
/**
* @brief nativeLoadResource
* TODO: This method is unfinished!
*/
static jboolean nativeLoadResource(JNIEnv* env, jobject jthis, jobject resource)
{
	SYSLOG("load resource");

	char* resourceBuffer = (char*)env->GetDirectBufferAddress(resource);

	// TODO: Now what?
}
示例#11
0
bool PRODUCT_NAME::init(OSDictionary *dict) {
	if (!IOService::init(dict)) {
		SYSLOG("init @ failed to initalise the parent");
		return false;
	}
	
	return true;
}
示例#12
0
void
dest(string f)
{
	if(catch( destruct_object(find_object( XML_DIR + f)) )) {
		SYSLOG("failed to destruct '" + XML_DIR + f + "'...\n");
		return;
	}
}
示例#13
0
static void signal_handler(int signum) {
	signal(signum, SIG_DFL);

	printf("Received signal %d (%s), exiting.\n", signum, strsignal(signum));
	SYSLOG(LOG_NOTICE, "Received signal %d (%s), exiting.", signum, strsignal(signum));
	teardown();
	exit(EXIT_SUCCESS);
}
示例#14
0
    int getPermissions(const char *key,const char *obj,IUserDescriptor *udesc,unsigned auditflags)
    {
        if (!ldapsecurity||((getLDAPflags()&DLF_ENABLED)==0)) 
            return 255;
        bool filescope = stricmp(key,"Scope")==0;
        bool wuscope = stricmp(key,"workunit")==0;
        if (filescope||wuscope) {
            StringBuffer username;
            StringBuffer password;
            int perm = 0;
            if (udesc) {
                udesc->getUserName(username);
                udesc->getPassword(password);
            }
            if (username.length()==0)  {
#ifndef _NO_DALIUSER_STACKTRACE
                DBGLOG("UNEXPECTED USER (NULL) in daldap.cpp getPermissions() line %d", __LINE__);
                //following debug code to be removed
                PrintStackReport();
#endif
                username.append(filesdefaultuser);
                decrypt(password, filesdefaultpassword);
            }
            unsigned start = msTick();
            Owned<ISecUser> user = ldapsecurity->createUser(username);
            if (user) {
                user->credentials().setPassword(password);
                if (filescope)
                    perm=ldapsecurity->authorizeFileScope(*user, obj);
                else if (wuscope)
                    perm=ldapsecurity->authorizeWorkunitScope(*user, obj);
                if (perm==-1)
                    perm = 0;
            }
            unsigned taken = msTick()-start;
#ifndef _DEBUG
            if (taken>100) 
#endif
            {
                PROGLOG("LDAP: getPermissions(%s) scope=%s user=%s returns %d in %d ms",key?key:"NULL",obj?obj:"NULL",username.str(),perm,taken);
            }
            if (auditflags&DALI_LDAP_AUDIT_REPORT) {
                StringBuffer auditstr;
                if ((auditflags&DALI_LDAP_READ_WANTED)&&!HASREADPERMISSION(perm)) 
                    auditstr.append("Lookup Access Denied");
                else if ((auditflags&DALI_LDAP_WRITE_WANTED)&&!HASWRITEPERMISSION(perm)) 
                    auditstr.append("Create Access Denied");
                if (auditstr.length()) {
                    auditstr.append(":\n\tProcess:\tdaserver");
                    auditstr.appendf("\n\tUser:\t%s",username.str());
                    auditstr.appendf("\n\tScope:\t%s\n",obj?obj:"");
                    SYSLOG(AUDIT_TYPE_ACCESS_FAILURE,auditstr.str());
                }
            }
            return perm;
        }
        return 255;
    }
示例#15
0
/*
 * open_files - open the shadow database
 *
 *	In read-only mode, the databases are not locked and are opened
 *	only for reading.
 */
static void open_files (void)
{
	/*
	 * Lock the files if we aren't in "read-only" mode
	 */
	if (!read_only) {
		if (pw_lock () == 0) {
			fprintf (stderr,
			         _("%s: cannot lock %s; try again later.\n"),
			         Prog, pwd_file);
			fail_exit (E_CANTLOCK);
		}
		pw_locked = true;
		if (is_shadow) {
			if (spw_lock () == 0) {
				fprintf (stderr,
				         _("%s: cannot lock %s; try again later.\n"),
				         Prog, spw_file);
				fail_exit (E_CANTLOCK);
			}
			spw_locked = true;
		}
	}

	/*
	 * Open the files. Use O_RDONLY if we are in read_only mode, O_RDWR
	 * otherwise.
	 */
	if (pw_open (read_only ? O_RDONLY : O_RDWR) == 0) {
		fprintf (stderr, _("%s: cannot open %s\n"),
		         Prog, pwd_file);
		if (use_system_pw_file) {
			SYSLOG ((LOG_WARN, "cannot open %s", pwd_file));
		}
		fail_exit (E_CANTOPEN);
	}
	if (is_shadow && (spw_open (read_only ? O_RDONLY : O_RDWR) == 0)) {
		fprintf (stderr, _("%s: cannot open %s\n"),
		         Prog, spw_file);
		if (use_system_spw_file) {
			SYSLOG ((LOG_WARN, "cannot open %s", spw_file));
		}
		fail_exit (E_CANTOPEN);
	}
}
示例#16
0
void KernelPatcher::applyLookupPatch(const LookupPatch *patch) {
	if (!patch || !patch->kext || patch->kext->loadIndex == KextInfo::Unloaded) {
		SYSLOG("patcher @ an invalid lookup patch provided");
		code = Error::MemoryIssue;
		return;
	}
	
	uint8_t *off, *curr;
	size_t size;
	auto kinfo = kinfos[patch->kext->loadIndex];
	kinfo->getRunningPosition(off, size);
	
	curr = off;
	off += size - patch->size;
	size_t changes {0};
	
	if (kinfo->setKernelWriting(true) != KERN_SUCCESS) {
		SYSLOG("patcher @ lookup patching failed to write to kernel");
		code = Error::MemoryProtection;
		return;
	}
	
	for (size_t i = 0; curr < off && (i < patch->count || patch->count == 0); i++) {
		while (curr < off && memcmp(curr, patch->find, patch->size))
			curr++;
		
		if (curr != off) {
			for (size_t j = 0; j < patch->size; j++) {
				curr[j] = patch->replace[j];
			}
			changes++;
		}
	}
	
	if (kinfo->setKernelWriting(false) != KERN_SUCCESS) {
		SYSLOG("patcher @ lookup patching failed to disable kernel writing");
		code = Error::MemoryProtection;
		return;
	}
	
	if (changes != patch->count) {
		SYSLOG("patcher @ lookup patching applied only %zu patches out of %zu", changes, patch->count);
		code = Error::MemoryIssue;
	}
}
示例#17
0
文件: script.c 项目: queensun/qtun
int script_signature_verify(lua_State* lua, const unsigned char signature[31]) {
    lua_getglobal(lua, "signature_verify");
    lua_pushlstring(lua, (char*)signature, 31);
    if (lua_pcall(lua, 1, 1, 0) != 0) {
        SYSLOG(LOG_ERR, "%s\n", lua_tostring(lua, -1));
        return 0;
    }
    return lua_toboolean(lua, -1);
}
示例#18
0
int fdwatch_remove(FDWATCH_HANDLE handle, FDWATCH_ITEM* item)
{
	if(epoll_ctl(handle->epollfd, EPOLL_CTL_DEL, fdwatch_getfd(item), NULL)==-1) {
		SYSLOG(LOG_ERROR, MODULE_NAME, "fdwatch_remove(epoll) : epoll_ctl() fail, errno()=%d", errno);
		return ERR_UNKNOWN;
	}

	return ERR_NOERROR;
}
示例#19
0
static void teardown() {
	printf("Exiting.\n");
	SYSLOG(LOG_NOTICE, "Exiting.");
	
	input_xarcade_close(&xarcdev);
	uinput_gpad_close(&uinp_gpads[0]);
	uinput_gpad_close(&uinp_gpads[1]);
	uinput_kbd_close(&uinp_kbd);
}
示例#20
0
文件: pwunconv.c 项目: Romutk/SPIVT1
static void fail_exit (int status)
{
	if (spw_locked) {
		if (spw_unlock () == 0) {
			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
			SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
			/* continue */
		}
	}
	if (pw_locked) {
		if (pw_unlock () == 0) {
			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
			SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
			/* continue */
		}
	}
	exit (status);
}
void UserPatcher::patchBinary(vm_map_t map, const char *path, uint32_t len) {
	if (patchDyldSharedCache && sharedCacheSlideStored) {
		patchSharedCache(map, storedSharedCacheSlide, CPU_TYPE_X86_64);
	} else {
		if (patchDyldSharedCache) SYSLOG("user @ no slide present, initialisation failed, fallback to restrict");
		injectRestrict(map);
	}
	userCallback.first(userCallback.second, *this, map, path, len);
}
示例#22
0
文件: socketapi.c 项目: Windeal/Demo
int Connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
    if (connect(sockfd, addr, addrlen) == -1)                                                                                                                    
    {       
        SYSLOG(LOG_ERR, errno, "ERROR: connected failed!\n");
        exit(errno);
    }    	
	return 0;
}
示例#23
0
文件: clip.c 项目: kai4785/LM
PDL_bool PDL_acl_license(PDL_JSParameters *params)
{
    /* This is where we need to do the work .*/
    int success = 0;
    //success = acl_license(argv[1]);
    SYSLOG(LOG_INFO, "***** plugin acl_license called");
    success = acl_license(NULL);
    return PDL_TRUE;
}
示例#24
0
文件: socketapi.c 项目: Windeal/Demo
int Listen(int sockfd, int backlog)
{
	if (listen(sockfd, backlog) == -1)
	{
		SYSLOG(LOG_ERR, errno, "ERROR: listen() failed!\n");
		exit(errno);
	}

}
示例#25
0
文件: socketapi.c 项目: Windeal/Demo
int Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
	if (bind(sockfd, addr, addrlen) == -1)
	{  
		SYSLOG(LOG_ERR, errno, "ERROR: Bind failed\n");
		exit(errno);
	} 		
	return 0;
}
示例#26
0
mach_vm_address_t KernelPatcher::createTrampoline(mach_vm_address_t func, size_t min) {
	if (!disasm.init()) {
		SYSLOG("patcher @ failed to use disasm");
		code = Error::DisasmFailure;
		return 0;
	}
	
	// Relative destination offset
	size_t off = disasm.instructionSize(func, min);
	
	if (!off || off > PAGE_SIZE - LongJump) {
		SYSLOG("patcher @ unsupported destination offset %zu", off);
		code = Error::DisasmFailure;
		return 0;
	}
	
	uint8_t *tempDataPtr = reinterpret_cast<uint8_t *>(tempExecutableMemory) + tempExecutableMemoryOff;
	
	tempExecutableMemoryOff += off + LongJump;
	
	if (tempExecutableMemoryOff >= TempExecutableMemorySize) {
		SYSLOG("patcher @ not enough executable memory requested %lld have %zu", tempExecutableMemoryOff+1, TempExecutableMemorySize);
		code = Error::DisasmFailure;
	} else if (kinfos[KernelID]->setKernelWriting(true) == KERN_SUCCESS) {
		// Copy the prologue, assuming it is PIC
		memcpy(tempDataPtr, reinterpret_cast<void *>(func), off);
	
		// Add a jump
		routeFunction(reinterpret_cast<mach_vm_address_t>(tempDataPtr+off), func+off, false, false);
		
		kinfos[KernelID]->setKernelWriting(false);
		
		if (getError() == Error::NoError) {
			return reinterpret_cast<mach_vm_address_t>(tempDataPtr);
		} else {
			SYSLOG("patcher @ failed to route an inner trempoline");
		}
	} else {
		SYSLOG("patcher @ failed to set executable permissions");
		code = Error::MemoryProtection;
	}
	
	return 0;
}
示例#27
0
/**
* @brief nativeLoadResource
*/
static jboolean nativeLoadResource(
	JNIEnv* env,
	jobject jthis,
	jobject resource,
	jlong resourceOffset,
	MAHandle handle,
	MAHandle placeholder)
{
	SYSLOG("load resource");

	int resFd = -1;

	if (resourceOffset != 0)
	{
		SYSLOG("MoSyncBridge.cpp: nativeLoad: Get resource file descriptor");
		jclass fdClass = env->FindClass("java/io/FileDescriptor");
		if (fdClass != NULL)
		{
			//jclass fdResClassRef = (jclass) env->NewGlobalRef(fdClass2);
			jfieldID fdClassDescriptorFieldID =
				env->GetFieldID(fdClass, "descriptor", "I");
				//env->GetFieldID(fdResClassRef, "descriptor", "I");

			if (fdClassDescriptorFieldID != NULL && resource != NULL)
			{
				jint fd = env->GetIntField(
					resource,
					fdClassDescriptorFieldID);
				resFd = dup(fd);
				lseek(resFd, resourceOffset, SEEK_SET);
			}
			else if (resource == NULL)
			{
				resFd = -1;
			}
		}
	}

	if (resFd > 0)
	{
		Base::FileStream res(resFd);
		Base::gSyscall->loadResource(res, handle, placeholder);
	}
}
示例#28
0
/*
 * open_files - open the shadow database
 *
 *	In read-only mode, the databases are not locked and are opened
 *	only for reading.
 */
static void open_files (bool readonly)
{
	/*
	 * Lock and open the password file. This loads all of the password
	 * file entries into memory. Then we get a pointer to the password
	 * file entry for the requested user.
	 */
	if (!readonly) {
		if (pw_lock () == 0) {
			fprintf (stderr,
			         _("%s: cannot lock %s; try again later.\n"),
			         Prog, pw_dbname ());
			fail_exit (E_NOPERM);
		}
		pw_locked = true;
	}
	if (pw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
		fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
		SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
		fail_exit (E_NOPERM);
	}

	/*
	 * For shadow password files we have to lock the file and read in
	 * the entries as was done for the password file. The user entries
	 * does not have to exist in this case; a new entry will be created
	 * for this user if one does not exist already.
	 */
	if (!readonly) {
		if (spw_lock () == 0) {
			fprintf (stderr,
			         _("%s: cannot lock %s; try again later.\n"),
			         Prog, spw_dbname ());
			fail_exit (E_NOPERM);
		}
		spw_locked = true;
	}
	if (spw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
		fprintf (stderr,
		         _("%s: cannot open %s\n"), Prog, spw_dbname ());
		SYSLOG ((LOG_WARN, "cannot open %s", spw_dbname ()));
		fail_exit (E_NOPERM);
	}
}
示例#29
0
文件: network.c 项目: queensun/qtun
ssize_t read_msg_t(client_t* client, msg_t** msg, double timeout)
{
    if (qtun->use_udp)
    {
        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, qtun->recv_buffer_len);
        return read_t(client, *msg, qtun->recv_buffer_len, timeout);
    }
    else
    {
        ssize_t rc;
        size_t len;

        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, sizeof(msg_t));
        if (*msg == NULL) return -2;
        rc = read_t(client, *msg, sizeof(**msg), timeout);
        if (rc <= 0)
        {
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return rc;
        }
        len = msg_data_length(*msg);
        *msg = pool_room_realloc(&qtun->pool, RECV_ROOM_IDX, sizeof(msg_t) + len);
        if (*msg == NULL) return -2;
        rc = read_t(client, (*msg)->data, len, timeout);
        if (rc <= 0 && len)
        {
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return rc;
        }

        if (checksum(*msg, sizeof(msg_t) + len))
        {
            SYSLOG(LOG_ERR, "Invalid msg");
            pool_room_free(&qtun->pool, RECV_ROOM_IDX);
            *msg = NULL;
            return -2;
        }

        SYSLOG(LOG_INFO, "read msg length: %lu", (unsigned long)len);
        return rc + sizeof(msg_t);
    }
}
示例#30
0
文件: socketapi.c 项目: Windeal/Demo
int Accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
	int clientfd;
	if ( (clientfd = accept(sockfd, addr, addrlen)) == -1 )
	{
		SYSLOG(LOG_ERR, errno, "ERROR: Accept failed()!\n");
		exit(errno);
	}
	return clientfd;
}