• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dropbear_log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dropbear_log函数的典型用法代码示例。如果您正苦于以下问题:C++ dropbear_log函数的具体用法?C++ dropbear_log怎么用?C++ dropbear_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dropbear_log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ccn_publish_client_mountpoint

static void
ccn_publish_client_mountpoint()
{
    dropbear_log(LOG_WARNING,"Enter ccn_publish_client_mountpoint");
    int result;
    struct ccn_charbuf *mountpoint;
    char client_id_str[6];
    char *client_name_str = NULL;

    mountpoint = ccn_charbuf_create();
    if( mountpoint == NULL )
        dropbear_exit("Failed to allocate client mountpoint charbuf");

    client_name_str = strdup((const char*)cli_opts.ccnxdomain);
    strcat(client_name_str,"/ssh/");
    sprintf(client_id_str,"%6d",rand());
    strcat(client_name_str,client_id_str);
    cli_opts.ccnxdomain = client_name_str;

    result = ccn_name_from_uri(mountpoint,cli_opts.ccnxdomain);
    if( result < 0 )
        dropbear_exit("Can't resolve client domain");

    dropbear_log(LOG_WARNING,"Listening at");
    print_ccnb_charbuf(mountpoint);
    result = ccn_set_interest_filter(cli_opts.ssh_ccn,mountpoint,&newServerAction);
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:27,代码来源:cli-main.c


示例2: utmp_write_direct

/* This is a slightly modification of code in OpenBSD's login.c */
static int
utmp_write_direct(struct logininfo *li, struct utmp *ut)
{
	return 1;
#if 0
	struct utmp old_ut;
	register int fd;
	int tty;

	/* FIXME: (ATL) ttyslot() needs local implementation */

#if defined(HAVE_GETTTYENT)
	register struct ttyent *ty;

	tty=0;

	setttyent();
	while ((struct ttyent *)0 != (ty = getttyent())) {
		tty++;
		if (!strncmp(ty->ty_name, ut->ut_line, sizeof(ut->ut_line)))
			break;
	}
	endttyent();

	if((struct ttyent *)0 == ty) {
		dropbear_log(LOG_WARNING, "utmp_write_entry: tty not found");
		return(1);
	}
#else /* FIXME */

	tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */

#endif /* HAVE_GETTTYENT */

	if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) {
		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
		/*
		 * Prevent luser from zero'ing out ut_host.
		 * If the new ut_line is empty but the old one is not
		 * and ut_line and ut_name match, preserve the old ut_line.
		 */
		if (atomicio(read, fd, &old_ut, sizeof(old_ut)) == sizeof(old_ut) &&
			(ut->ut_host[0] == '\0') && (old_ut.ut_host[0] != '\0') &&
			(strncmp(old_ut.ut_line, ut->ut_line, sizeof(ut->ut_line)) == 0) &&
			(strncmp(old_ut.ut_name, ut->ut_name, sizeof(ut->ut_name)) == 0)) {
			(void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host));
		}

		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
		if (atomicio(write, fd, ut, sizeof(*ut)) != sizeof(*ut))
			dropbear_log(LOG_WARNING, "utmp_write_direct: error writing %s: %s",
			    UTMP_FILE, strerror(errno));

		(void)close(fd);
		return 1;
	} else {
		return 0;
	}
#endif
}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:61,代码来源:loginrec.c


示例3: buf_writefile

/* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
static int buf_writefile(buffer * buf, const char * filename) {
	int ret = DROPBEAR_FAILURE;
	int fd = -1;

	fd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
	if (fd < 0) {
		dropbear_log(LOG_ERR, "Couldn't create new file %s: %s",
			filename, strerror(errno));
		goto out;
	}

	/* write the file now */
	while (buf->pos != buf->len) {
		int len = write(fd, buf_getptr(buf, buf->len - buf->pos),
				buf->len - buf->pos);
		if (errno == EINTR) {
			continue;
		}
		if (len <= 0) {
			dropbear_log(LOG_ERR, "Failed writing file %s: %s",
				filename, strerror(errno));
			goto out;
		}
		buf_incrpos(buf, len);
	}

	ret = DROPBEAR_SUCCESS;

out:
	if (fd >= 0) {
		m_close(fd);
	}
	return ret;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:35,代码来源:gensignkey.c


示例4: pty_setowner

void
pty_setowner(struct passwd *pw, const char *tty_name)
{
	struct group *grp;
	gid_t gid;
	mode_t mode;
	struct stat st;

	/* Determine the group to make the owner of the tty. */
	grp = getgrnam("tty");
	if (grp) {
		gid = grp->gr_gid;
		mode = S_IRUSR | S_IWUSR | S_IWGRP;
	} else {
		gid = pw->pw_gid;
		mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
	}

	/*
	 * Change owner and mode of the tty as required.
	 * Warn but continue if filesystem is read-only and the uids match/
	 * tty is owned by root.
	 */
	if (stat(tty_name, &st)) {
		dropbear_exit("pty_setowner: stat(%.101s) failed: %.100s",
				tty_name, strerror(errno));
	}

	if (st.st_uid != pw->pw_uid || st.st_gid != gid) {
		if (chown(tty_name, pw->pw_uid, gid) < 0) {
			if (errno == EROFS &&
			    (st.st_uid == pw->pw_uid || st.st_uid == 0)) {
				dropbear_log(LOG_ERR,
					"chown(%.100s, %u, %u) failed: %.100s",
						tty_name, (unsigned int)pw->pw_uid, (unsigned int)gid,
						strerror(errno));
			} else {
				dropbear_exit("chown(%.100s, %u, %u) failed: %.100s",
				    tty_name, (unsigned int)pw->pw_uid, (unsigned int)gid,
				    strerror(errno));
			}
		}
	}

	if ((st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) != mode) {
		if (chmod(tty_name, mode) < 0) {
			if (errno == EROFS &&
			    (st.st_mode & (S_IRGRP | S_IROTH)) == 0) {
				dropbear_log(LOG_ERR,
					"chmod(%.100s, 0%o) failed: %.100s",
					tty_name, mode, strerror(errno));
			} else {
				dropbear_exit("chmod(%.100s, 0%o) failed: %.100s",
				    tty_name, mode, strerror(errno));
			}
		}
	}
}
开发者ID:gvsurenderreddy,项目名称:uclinux-users,代码行数:58,代码来源:sshpty.c


示例5: svr_auth_password

/* Process a password auth request, sending success or failure messages as
 * appropriate */
void svr_auth_password() {
	
	char * passwdcrypt = NULL; /* the crypt from /etc/passwd or /etc/shadow */
	char * testcrypt = NULL; /* crypt generated from the user's password sent */
	unsigned char * password;
	unsigned int passwordlen;

	unsigned int changepw;

	passwdcrypt = ses.authstate.pw_passwd;

#ifdef DEBUG_HACKCRYPT
	/* debugging crypt for non-root testing with shadows */
	passwdcrypt = DEBUG_HACKCRYPT;
#endif

	/* check if client wants to change password */
	changepw = buf_getbool(ses.payload);
	if (changepw) {
		/* not implemented by this server */
		send_msg_userauth_failure(0, 1);
		return;
	}

	password = buf_getstring(ses.payload, &passwordlen);

	/* the first bytes of passwdcrypt are the salt */
	testcrypt = crypt((char*)password, passwdcrypt);
	m_burn(password, passwordlen);
	m_free(password);

	/* check for empty password */
	if (passwdcrypt[0] == '\0') {
		dropbear_log(LOG_WARNING, "User '%s' has blank password, rejected",
				ses.authstate.pw_name);
		send_msg_userauth_failure(0, 1);
		return;
	}

	if (strcmp(testcrypt, passwdcrypt) == 0) {
		/* successful authentication */
		dropbear_log(LOG_NOTICE, 
				"Password auth succeeded for '%s' from %s",
				ses.authstate.pw_name,
				svr_ses.addrstring);
		send_msg_userauth_success();
	} else {
		dropbear_log(LOG_WARNING,
				"Bad password attempt for '%s' from %s",
				ses.authstate.pw_name,
				svr_ses.addrstring);
		send_msg_userauth_failure(0, 1);
	}
}
开发者ID:yath,项目名称:dropbear,代码行数:56,代码来源:svr-authpasswd.c


示例6: ccn_ssh_connect

void
ccn_ssh_connect(char *remote_name_str)
{
    dropbear_log(LOG_WARNING,"Enter ccn_ssh_connect");
    int result;
    struct ccn_charbuf *remote_name;
/*
    struct ccn_pkey *server_pkey;
    void *encrypted_local_name;
    size_t encrypted_local_name_length;
*/

    struct ccn_charbuf *connect_template;


    remote_name = ccn_charbuf_create();
    result = ccn_name_from_uri(remote_name,remote_name_str);
    if( result < 0 )
        dropbear_exit("Could not parse server uri");

    ccn_name_append_str(remote_name,"ssh");
    ccn_name_append_str(remote_name,"client");

    /*
    server_pkey = ssh_ccn_retrieve_public_key(
            cli_opts.ssh_ccn,
            cli_opts.remote_name_str,
            cli_opts.ccn_cached_keystore);
    if( server_pkey == NULL )
        dropbear_exit("Could not get server public key");

    result = ccn_pubkey_encrypt(server_pkey,
            cli_opts.ccnxdomain,
            strlen(cli_opts.ccnxdomain),
            &encrypted_local_name,
            &encrypted_local_name_length);

    ccn_name_append(remote_name,encrypted_local_name);
    */
    ccn_name_append(remote_name,cli_opts.ccnxdomain,strlen(cli_opts.ccnxdomain));

    dropbear_log(LOG_WARNING,"Connecting to remote:");
    print_ccnb_charbuf(remote_name);

    connect_template = make_connect_template();

    result = ccn_express_interest(cli_opts.ssh_ccn,
            remote_name,
            &newServerAction,
            connect_template);
    if( result < 0 )
        dropbear_exit("Failed to express interest to server");
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:53,代码来源:cli-main.c


示例7: pty_release

void
pty_release(const char *tty_name)
{
	if (chown(tty_name, (uid_t) 0, (gid_t) 0) < 0
			&& (errno != ENOENT)) {
		dropbear_log(LOG_ERR,
				"chown %.100s 0 0 failed: %.100s", tty_name, strerror(errno));
	}
	if (chmod(tty_name, (mode_t) 0666) < 0
			&& (errno != ENOENT)) {
		dropbear_log(LOG_ERR,
			"chmod %.100s 0666 failed: %.100s", tty_name, strerror(errno));
	}
}
开发者ID:gvsurenderreddy,项目名称:uclinux-users,代码行数:14,代码来源:sshpty.c


示例8: cli_dropbear_exit

static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {

	char fmtbuf[300];
	char exitmsg[500];

	if (!sessinitdone) {
		snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s",
				format);
	} else {
		snprintf(fmtbuf, sizeof(fmtbuf), 
				"Connection to %[email protected]%s:%s exited: %s", 
				cli_opts.username, cli_opts.remotehost, 
				cli_opts.remoteport, format);
	}

	/* Arguments to the exit printout may be unsafe to use after session_cleanup() */
	vsnprintf(exitmsg, sizeof(exitmsg), fmtbuf, param);

	/* Do the cleanup first, since then the terminal will be reset */
	session_cleanup();
	/* Avoid printing onwards from terminal cruft */
	fprintf(stderr, "\n");

	dropbear_log(LOG_INFO, "%s", exitmsg);;
	exit(exitcode);
}
开发者ID:jing-git,项目名称:rt-n56u-1,代码行数:26,代码来源:cli-main.c


示例9: cli_dropbear_exit

static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
	char exitmsg[150];
	char fullmsg[300];

	/* Note that exit message must be rendered before session cleanup */

	/* Render the formatted exit message */
	vsnprintf(exitmsg, sizeof(exitmsg), format, param);

	/* Add the prefix depending on session/auth state */
	if (!sessinitdone) {
		snprintf(fullmsg, sizeof(fullmsg), "Exited: %s", exitmsg);
	} else {
		snprintf(fullmsg, sizeof(fullmsg), 
				"Connection to %[email protected]%s:%s exited: %s", 
				cli_opts.username, cli_opts.remotehost, 
				cli_opts.remoteport, exitmsg);
	}

	/* Do the cleanup first, since then the terminal will be reset */
	session_cleanup();
	/* Avoid printing onwards from terminal cruft */
	fprintf(stderr, "\n");

	dropbear_log(LOG_INFO, "%s", fullmsg);
	exit(exitcode);
}
开发者ID:Geofferey,项目名称:dropbear,代码行数:27,代码来源:cli-main.c


示例10: login_write

/**
 ** login_write: Call low-level recording functions based on autoconf
 ** results
 **/
int
login_write (struct logininfo *li)
{
#ifndef HAVE_CYGWIN
	if ((int)geteuid() != 0) {
	  dropbear_log(LOG_WARNING,
			  "Attempt to write login records by non-root user (aborting)");
	  return 1;
	}
#endif

	/* set the timestamp */
	login_set_current_time(li);
#ifdef USE_LOGIN
	syslogin_write_entry(li);
#endif
#ifdef USE_LASTLOG
	if (li->type == LTYPE_LOGIN) {
		lastlog_write_entry(li);
	}
#endif
#ifdef USE_UTMP
	utmp_write_entry(li);
#endif
#ifdef USE_WTMP
	wtmp_write_entry(li);
#endif
#ifdef USE_UTMPX
	utmpx_write_entry(li);
#endif
#ifdef USE_WTMPX
	wtmpx_write_entry(li);
#endif
	return 0;
}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:39,代码来源:loginrec.c


示例11: bindport

/* returns the port bound to, or -1 on failure.
 * Will attempt to bind to a port X11BINDBASE (6010 usually) or upwards */
static int bindport(int fd) {

	struct sockaddr_in addr;
	uint16_t port;

	memset((void*)&addr, 0x0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

	/* if we can't find one in 2000 ports free, something's wrong */
	for (port = X11BINDBASE; port < X11BINDBASE + 2000; port++) {
		addr.sin_port = htons(port);
		if (bind(fd, (struct sockaddr*)&addr, 
					sizeof(struct sockaddr_in)) == 0) {
			/* success */
			return port;
		}
		if (errno == EADDRINUSE) {
			/* try the next port */
			continue;
		}
		/* otherwise it was an error we don't know about */
		dropbear_log(LOG_DEBUG, "Failed to bind x11 socket");
		break;
	}
	return -1;
}
开发者ID:WhitePatches,项目名称:snake-os,代码行数:29,代码来源:svr-x11fwd.c


示例12: newtcpforwarded

static int newtcpforwarded(struct Channel * channel) {

    char *origaddr = NULL;
	unsigned int origport;
	m_list_elem * iter = NULL;
	struct TCPFwdEntry *fwd;
	char portstring[NI_MAXSERV];
	int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED;

	origaddr = buf_getstring(ses.payload, NULL);
	origport = buf_getint(ses.payload);

	/* Find which port corresponds. First try and match address as well as port,
	in case they want to forward different ports separately ... */
	for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
		fwd = (struct TCPFwdEntry*)iter->item;
		if (origport == fwd->listenport
				&& strcmp(origaddr, fwd->listenaddr) == 0) {
			break;
		}
	}

	if (!iter)
	{
		/* ... otherwise try to generically match the only forwarded port 
		without address (also handles ::1 vs 127.0.0.1 vs localhost case).
		rfc4254 is vague about the definition of "address that was connected" */
		for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
			fwd = (struct TCPFwdEntry*)iter->item;
			if (origport == fwd->listenport) {
				break;
			}
		}
	}


	if (iter == NULL) {
		/* We didn't request forwarding on that port */
        	cleantext(origaddr);
		dropbear_log(LOG_INFO, "Server sent unrequested forward from \"%s:%d\"", 
                origaddr, origport);
		goto out;
	}
	
	snprintf(portstring, sizeof(portstring), "%d", fwd->connectport);
	channel->conn_pending = connect_remote(AF_UNSPEC, fwd->connectaddr,
					portstring, channel_connect_done, channel);

	channel->prio = DROPBEAR_CHANNEL_PRIO_UNKNOWABLE;
	
	err = SSH_OPEN_IN_PROGRESS;

out:
	m_free(origaddr);
	TRACE(("leave newtcpdirect: err %d", err))
	return err;
}
开发者ID:jing-git,项目名称:rt-n56u-1,代码行数:57,代码来源:cli-tcpfwd.c


示例13: ccn_publish_host_key

static void
ccn_publish_host_key()
{
    dropbear_log(LOG_WARNING,"Enter ccn_publish_host_key");
    if( ccn_publish_key(cli_opts.ssh_ccn,
                cli_opts.ccn_cached_keystore,
                cli_opts.ccnxdomain) < 0 )
        dropbear_exit("Could not publish ccn host key");
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:9,代码来源:cli-main.c


示例14: utmpx_perform_login

static int
utmpx_perform_login(struct logininfo *li)
{
	struct utmpx utx;

	construct_utmpx(li, &utx);
# ifdef UTMPX_USE_LIBRARY
	if (!utmpx_write_library(li, &utx)) {
		dropbear_log(LOG_WARNING, "utmpx_perform_login: utmp_write_library() failed");
		return 0;
	}
# else
	if (!utmpx_write_direct(li, &ut)) {
		dropbear_log(LOG_WARNING, "utmpx_perform_login: utmp_write_direct() failed");
		return 0;
	}
# endif
	return 1;
}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:19,代码来源:loginrec.c


示例15: newServerHandler

/*
 * newServerHandler
 *
 * Expecting a string containing the URI for the client
 */
static enum ccn_upcall_res
newServerHandler(struct ccn_closure *selfp,
        enum ccn_upcall_kind kind,
        struct ccn_upcall_info *info)
{
    dropbear_log(LOG_WARNING,"Enter newServerHandler");
    dropbear_log(LOG_WARNING,"Got interest matching %d components, kind = %d\n", info->matched_comps, kind);
    int result;

    const unsigned char *ccnb = NULL;
    size_t ccnb_size;

    void *data = NULL;
    size_t data_size = 0;

    switch (kind) {
        case CCN_UPCALL_CONTENT:
            break;
        case CCN_UPCALL_INTEREST_TIMED_OUT:
            return CCN_UPCALL_RESULT_REEXPRESS;
        case CCN_UPCALL_CONTENT_UNVERIFIED:
            // TODO: fix verification
            break;
        default:
            return CCN_UPCALL_RESULT_ERR;
    }

    dropbear_log(LOG_WARNING,"Interest to");
    print_ccnb_name(info);

    ccnb = info->content_ccnb;
    ccnb_size = info->pco->offset[CCN_PCO_E];

    result = ccn_content_get_value(ccnb, ccnb_size, info->pco, (const unsigned char **)&data, &data_size);
    if( result < 0 )
        dropbear_exit("Could not parse reply message");

    dropbear_log(LOG_WARNING,"newServerHandler: parsing contents");
    if( strncmp((char *)data,"ccnx:/",6) == 0 ) {
        cli_opts.remote_name_str = (char *)data;
        dropbear_log(LOG_WARNING,"newServerHandler: matches: %s (%d)",data,data_size);
        ses.remote_name = ccn_charbuf_create();
        result = ccn_name_from_uri(ses.remote_name,cli_opts.remote_name_str);
        if( result < 0 )
            dropbear_exit("Did not find expected uri in server response");

        // Start a new session
        dropbear_log(LOG_WARNING,"Connected to server at");
        print_ccnb_charbuf(ses.remote_name);
        
        cli_session(cli_opts.ccnxdomain,cli_opts.remote_name_str);

        return CCN_UPCALL_RESULT_OK;
    } else {
        dropbear_log(LOG_WARNING,"newServerHandler: doesn't match");
        return CCN_UPCALL_RESULT_ERR;
    }
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:63,代码来源:cli-main.c


示例16: lastlog_openseek

/* open the file (using filemode) and seek to the login entry */
static int
lastlog_openseek(struct logininfo *li, int *fd, int filemode)
{
	off_t offset;
	int type;
	char lastlog_file[1024];

	type = lastlog_filetype(LASTLOG_FILE);
	switch (type) {
		case LL_FILE:
			strlcpy(lastlog_file, LASTLOG_FILE, sizeof(lastlog_file));
			break;
		case LL_DIR:
			snprintf(lastlog_file, sizeof(lastlog_file), "%s/%s",
				 LASTLOG_FILE, li->username);
			break;
		default:
			dropbear_log(LOG_WARNING, "lastlog_openseek: %.100s is not a file or directory!",
			    LASTLOG_FILE);
			return 0;
	}

	*fd = open(lastlog_file, filemode, 0600);
	if ( *fd < 0) {
		dropbear_log(LOG_INFO, "lastlog_openseek: Couldn't open %s: %s",
		    lastlog_file, strerror(errno));
		return 0;
	}

	if (type == LL_FILE) {
		/* find this uid's offset in the lastlog file */
		offset = (off_t) ((long)li->uid * sizeof(struct lastlog));

		if ( lseek(*fd, offset, SEEK_SET) != offset ) {
			dropbear_log(LOG_WARNING, "lastlog_openseek: %s->lseek(): %s",
			 lastlog_file, strerror(errno));
			return 0;
		}
	}

	return 1;
}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:43,代码来源:loginrec.c


示例17: cli_recv_msg_request_failure

void cli_recv_msg_request_failure() {
	m_list_elem *iter;
	for (iter = cli_opts.remotefwds->first; iter; iter = iter->next) {
		struct TCPFwdEntry *fwd = (struct TCPFwdEntry*)iter->item;
		if (!fwd->have_reply) {
			fwd->have_reply = 1;
			dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", fwd->listenport, fwd->connectaddr, fwd->connectport);
			return;
		}
	}
}
开发者ID:schidler,项目名称:flyzjhz-rt-n56u,代码行数:11,代码来源:cli-tcpfwd.c


示例18: lastlog_write_entry

int
lastlog_write_entry(struct logininfo *li)
{
	switch(li->type) {
	case LTYPE_LOGIN:
		return lastlog_perform_login(li);
	default:
		dropbear_log(LOG_WARNING, "lastlog_write_entry: Invalid type field");
		return 0;
	}
}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:11,代码来源:loginrec.c


示例19: parse_ciphers_macs

void
parse_ciphers_macs()
{
	if (opts.cipher_list)
	{
		if (strcmp(opts.cipher_list, "help") == 0)
		{
			char *ciphers = algolist_string(sshciphers);
			dropbear_log(LOG_INFO, "Available ciphers:\n%s\n", ciphers);
			m_free(ciphers);
			dropbear_exit(".");
		}

		if (strcmp(opts.cipher_list, "none") == 0)
		{
			/* Encryption is required during authentication */
			opts.cipher_list = "none,aes128-ctr";
		}

		if (check_user_algos(opts.cipher_list, sshciphers, "cipher") == 0)
		{
			dropbear_exit("No valid ciphers specified for '-c'");
		}
	}

	if (opts.mac_list)
	{
		if (strcmp(opts.mac_list, "help") == 0)
		{
			char *macs = algolist_string(sshhashes);
			dropbear_log(LOG_INFO, "Available MACs:\n%s\n", macs);
			m_free(macs);
			dropbear_exit(".");
		}

		if (check_user_algos(opts.mac_list, sshhashes, "MAC") == 0)
		{
			dropbear_exit("No valid MACs specified for '-m'");
		}
	}
}
开发者ID:BBBSnowball,项目名称:mehari,代码行数:41,代码来源:common-runopts.c


示例20: open_known_hosts_file

static FILE* open_known_hosts_file(int * readonly)
{
	FILE * hostsfile = NULL;
	char * filename = NULL;
	char * homedir = NULL;
	
	homedir = getenv("HOME");

	if (!homedir) {
		struct passwd * pw = NULL;
		pw = getpwuid(getuid());
		if (pw) {
			homedir = pw->pw_dir;
#ifdef ANDROID_CHANGES
			if (strlen(homedir) <= 1) {
				TRACE(("(hosts_file) forcing DROPBEAR_HOME folder for user .ssh: " DROPBEAR_HOME ))
				homedir = DROPBEAR_HOME;
			}
#endif
		}
	}

	if (homedir) {
		unsigned int len;
		len = strlen(homedir);
		filename = m_malloc(len + 18); /* "/.ssh/known_hosts" and null-terminator*/

		snprintf(filename, len+18, "%s/.ssh", homedir);
		/* Check that ~/.ssh exists - easiest way is just to mkdir */
		if (mkdir(filename, S_IRWXU) != 0) {
			if (errno != EEXIST) {
				dropbear_log(LOG_INFO, "Warning: failed creating %s/.ssh: %s",
						homedir, strerror(errno));
				TRACE(("mkdir didn't work: %s", strerror(errno)))
				goto out;
			}
		}

		snprintf(filename, len+18, "%s/.ssh/known_hosts", homedir);
		hostsfile = fopen(filename, "a+");
		
		if (hostsfile != NULL) {
			*readonly = 0;
			fseek(hostsfile, 0, SEEK_SET);
		} else {
			/* We mightn't have been able to open it if it was read-only */
			if (errno == EACCES || errno == EROFS) {
					TRACE(("trying readonly: %s", strerror(errno)))
					*readonly = 1;
					hostsfile = fopen(filename, "r");
			}
		}
	}
开发者ID:Ar3kkusu,项目名称:android_external_dropbear,代码行数:53,代码来源:cli-kex.c



注:本文中的dropbear_log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ drtDescriptionSuitableForTestResult函数代码示例发布时间:2022-05-30
下一篇:
C++ dropbear_exit函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap