mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 18:55:19 +00:00 
			
		
		
		
	Flagify hold (bug #3456)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										7
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Makefile
									
									
									
									
									
								
							| @@ -494,6 +494,13 @@ samples: all datafiles adsi | ||||
| 		echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo "" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo "; Changing the following lines may compromise your security." >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo ";[files]" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo ";astctlpermissions = 0660" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo ";astctlowner = root" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo ";astctlgroup = apache" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 		echo ";astctl = asterisk.ctl" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \ | ||||
| 	else \ | ||||
| 		echo "Skipping asterisk.conf creation"; \ | ||||
| 	fi | ||||
|   | ||||
							
								
								
									
										67
									
								
								asterisk.c
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								asterisk.c
									
									
									
									
									
								
							| @@ -385,6 +385,16 @@ static int ast_makesocket(void) | ||||
| 	struct sockaddr_un sunaddr; | ||||
| 	int res; | ||||
| 	int x; | ||||
|  | ||||
| 	struct ast_config *cfg; | ||||
| 	char *config = ASTCONFPATH; | ||||
| 	char *owner; | ||||
| 	char *group; | ||||
| 	char *perms; | ||||
| 	uid_t uid; | ||||
| 	gid_t gid; | ||||
|  | ||||
|  | ||||
| 	for (x=0;x<AST_MAX_CONNECTS;x++)	 | ||||
| 		consoles[x].fd = -1; | ||||
| 	unlink((char *)ast_config_AST_SOCKET); | ||||
| @@ -412,6 +422,48 @@ static int ast_makesocket(void) | ||||
| 	} | ||||
| 	ast_register_verbose(network_verboser); | ||||
| 	ast_pthread_create(<hread, NULL, listener, NULL); | ||||
|  | ||||
| 	/* Load the options for owner, group and permissions from | ||||
| 	   asterisk.conf. if the file doesn't exist (????) just skip | ||||
| 	   this part. | ||||
| 	*/ | ||||
| 	if (option_overrideconfig == 1) { | ||||
| 		cfg = ast_config_load((char *)ast_config_AST_CONFIG_FILE); | ||||
| 	} else { | ||||
| 		cfg = ast_config_load(config); | ||||
| 	} | ||||
| 	if (!cfg) return 0; | ||||
|  | ||||
| 	gid=-1; | ||||
| 	uid=-1; | ||||
| 	group = ast_variable_retrieve(cfg, "files", "astctlgroup"); | ||||
| 	owner = ast_variable_retrieve(cfg, "files", "astctlowner"); | ||||
| 	perms = ast_variable_retrieve(cfg, "files", "astctlpermissions"); | ||||
|  | ||||
| 	if (owner!=NULL) { | ||||
| 		struct passwd *pw; | ||||
| 		if ((pw=getpwnam(owner))==NULL) | ||||
| 			ast_log(LOG_WARNING, "Unable to find uid of user %s\n", owner); | ||||
| 		else | ||||
| 			uid=pw->pw_uid; | ||||
| 	} | ||||
| 	if (group!=NULL) { | ||||
| 		struct group *grp; | ||||
| 		if ((grp=getgrnam(group))==NULL) | ||||
| 			ast_log(LOG_WARNING, "Unable to find gid of group %s\n", group); | ||||
| 		else | ||||
| 			gid=grp->gr_gid; | ||||
| 	} | ||||
| 	if (chown(ast_config_AST_SOCKET,uid,gid)<0) | ||||
| 		ast_log(LOG_WARNING, "Unable to change ownership of %s: %s\n", ast_config_AST_SOCKET,strerror(errno)); | ||||
|  | ||||
| 	if (perms!=NULL) { | ||||
| 		mode_t p; | ||||
| 		sscanf(perms,"%o",&p); | ||||
| 		if ((chmod(ast_config_AST_SOCKET,p))<0) | ||||
| 			ast_log(LOG_WARNING, "Unable to change file permissions of %s: %s\n", ast_config_AST_SOCKET,strerror(errno)); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| @@ -1495,6 +1547,7 @@ static int show_cli_help(void) { | ||||
| static void ast_readconfig(void) { | ||||
| 	struct ast_config *cfg; | ||||
| 	struct ast_variable *v; | ||||
| 	struct ast_variable *v_ctlfile; | ||||
| 	char *config = ASTCONFPATH; | ||||
|  | ||||
| 	if (option_overrideconfig == 1) { | ||||
| @@ -1522,6 +1575,14 @@ static void ast_readconfig(void) { | ||||
| 	if (!cfg) { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	v_ctlfile = ast_variable_browse(cfg, "files"); | ||||
| 	while (v_ctlfile!=NULL) { | ||||
| 		if (strcmp(v_ctlfile->name,"astctl")==0) | ||||
| 			break; | ||||
| 		v_ctlfile=v_ctlfile->next; | ||||
| 	} | ||||
|  | ||||
| 	v = ast_variable_browse(cfg, "directories"); | ||||
| 	while(v) { | ||||
| 		if (!strcasecmp(v->name, "astetcdir")) { | ||||
| @@ -1536,8 +1597,8 @@ static void ast_readconfig(void) { | ||||
| 		} else if (!strcasecmp(v->name, "astagidir")) { | ||||
| 			strncpy((char *)ast_config_AST_AGI_DIR,v->value,sizeof(ast_config_AST_AGI_DIR)-1); | ||||
| 		} else if (!strcasecmp(v->name, "astrundir")) { | ||||
| 			snprintf((char *)ast_config_AST_PID,sizeof(ast_config_AST_PID),"%s/%s",v->value,"asterisk.pid");     | ||||
| 			snprintf((char *)ast_config_AST_SOCKET,sizeof(ast_config_AST_SOCKET),"%s/%s",v->value,"asterisk.ctl");     | ||||
| 			snprintf((char *)ast_config_AST_PID,sizeof(ast_config_AST_PID),"%s/%s",v->value,"asterisk.pid"); | ||||
| 			snprintf((char *)ast_config_AST_SOCKET,sizeof(ast_config_AST_SOCKET),"%s/%s",v->value,v_ctlfile==NULL?"asterisk.ctl":v_ctlfile->value); | ||||
| 			strncpy((char *)ast_config_AST_RUN_DIR,v->value,sizeof(ast_config_AST_RUN_DIR)-1); | ||||
| 		} else if (!strcasecmp(v->name, "astmoddir")) { | ||||
| 			strncpy((char *)ast_config_AST_MODULE_DIR,v->value,sizeof(ast_config_AST_MODULE_DIR)-1); | ||||
| @@ -1793,7 +1854,7 @@ int main(int argc, char *argv[]) | ||||
| 			exit(1); | ||||
| 		} | ||||
| 	} else if (option_remote || option_exec) { | ||||
| 		ast_log(LOG_ERROR, "Unable to connect to remote asterisk\n"); | ||||
| 		ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n",ast_config_AST_SOCKET); | ||||
| 		printf(term_quit()); | ||||
| 		exit(1); | ||||
| 	} | ||||
|   | ||||
| @@ -302,6 +302,8 @@ struct sip_history { | ||||
| #define SIP_OSPAUTH_NO		(0 << 26) | ||||
| #define SIP_OSPAUTH_YES		(1 << 26) | ||||
| #define SIP_OSPAUTH_EXCLUSIVE	(2 << 26) | ||||
| /* Call states */ | ||||
| #define SIP_CALL_ONHOLD		(1 << 28) | ||||
|  | ||||
| /* a new page of flags */ | ||||
| #define SIP_PAGE2_RTCACHEFRIENDS 	(1 << 0) | ||||
| @@ -409,7 +411,6 @@ static struct sip_pvt { | ||||
| 	struct sip_history *history;		/* History of this SIP dialog */ | ||||
| 	struct ast_variable *vars; | ||||
| 	struct sip_pvt *next;			/* Next call in chain */ | ||||
| 	int onhold;				/* call on hold */ | ||||
| } *iflist = NULL; | ||||
|  | ||||
| #define FLAG_RESPONSE (1 << 0) | ||||
| @@ -2834,22 +2835,22 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) | ||||
| 			/* Turn on/off music on hold if we are holding/unholding */ | ||||
| 			if (sin.sin_addr.s_addr && !sendonly) { | ||||
| 				ast_moh_stop(ast_bridged_channel(p->owner)); | ||||
| 				if (callevents && p->onhold) { | ||||
| 				if (callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) { | ||||
| 					manager_event(EVENT_FLAG_CALL, "Unhold", | ||||
| 						"Channel: %s\r\n" | ||||
| 						"Uniqueid: %s\r\n", | ||||
| 						p->owner->name,  | ||||
| 						p->owner->uniqueid); | ||||
| 					p->onhold = 0; | ||||
| 					ast_clear_flag(p, SIP_CALL_ONHOLD); | ||||
| 				} | ||||
| 			} else { | ||||
| 				if (callevents && !p->onhold) { | ||||
| 				if (callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) { | ||||
| 					manager_event(EVENT_FLAG_CALL, "Hold", | ||||
| 						"Channel: %s\r\n" | ||||
| 						"Uniqueid: %s\r\n", | ||||
| 						p->owner->name,  | ||||
| 						p->owner->uniqueid); | ||||
| 						p->onhold = 1; | ||||
| 						ast_set_flag(p, SIP_CALL_ONHOLD); | ||||
| 				} | ||||
| 				ast_moh_start(ast_bridged_channel(p->owner), NULL); | ||||
| 				if (sendonly) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user