mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	client: set ucred properties
This commit is contained in:
		
							parent
							
								
									3334ed73ae
								
							
						
					
					
						commit
						ebea63ad0a
					
				
					 3 changed files with 19 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -1038,11 +1038,6 @@ static struct client *client_new(struct impl *impl, int fd)
 | 
			
		|||
	if (properties == NULL)
 | 
			
		||||
		goto no_props;
 | 
			
		||||
 | 
			
		||||
	if (ucredp) {
 | 
			
		||||
		pw_properties_setf(properties, "application.process.id", "%d", ucredp->pid);
 | 
			
		||||
		pw_properties_setf(properties, "application.process.userid", "%d", ucredp->uid);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
        client = pw_client_new(impl->core, pw_module_get_global(impl->module),
 | 
			
		||||
			       ucredp, properties, sizeof(struct client));
 | 
			
		||||
	if (client == NULL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -230,6 +230,7 @@ static struct pw_client *client_new(struct server *s, int fd)
 | 
			
		|||
	socklen_t len;
 | 
			
		||||
	struct ucred ucred, *ucredp;
 | 
			
		||||
	struct pw_core *core = protocol->core;
 | 
			
		||||
	struct pw_properties *props;
 | 
			
		||||
 | 
			
		||||
	len = sizeof(ucred);
 | 
			
		||||
	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -239,10 +240,14 @@ static struct pw_client *client_new(struct server *s, int fd)
 | 
			
		|||
		ucredp = &ucred;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	props = pw_properties_new("pipewire.protocol", "protocol-native", NULL);
 | 
			
		||||
	if (props == NULL)
 | 
			
		||||
		goto no_props;
 | 
			
		||||
 | 
			
		||||
	client = pw_client_new(protocol->core,
 | 
			
		||||
			       pw_module_get_global(pd->module),
 | 
			
		||||
			       ucredp,
 | 
			
		||||
			       NULL,
 | 
			
		||||
			       props,
 | 
			
		||||
			       sizeof(struct client_data));
 | 
			
		||||
	if (client == NULL)
 | 
			
		||||
		goto no_client;
 | 
			
		||||
| 
						 | 
				
			
			@ -272,6 +277,7 @@ static struct pw_client *client_new(struct server *s, int fd)
 | 
			
		|||
      no_source:
 | 
			
		||||
	pw_client_destroy(client);
 | 
			
		||||
      no_client:
 | 
			
		||||
      no_props:
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,6 +108,18 @@ struct pw_client *pw_client_new(struct pw_core *core,
 | 
			
		|||
	this->core = core;
 | 
			
		||||
	if ((this->ucred_valid = (ucred != NULL)))
 | 
			
		||||
		this->ucred = *ucred;
 | 
			
		||||
 | 
			
		||||
	if (properties == NULL)
 | 
			
		||||
		properties = pw_properties_new(NULL, NULL);
 | 
			
		||||
	if (properties == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	if (ucred) {
 | 
			
		||||
		pw_properties_setf(properties, "pipewire.ucred.pid", "%d", ucred->pid);
 | 
			
		||||
		pw_properties_setf(properties, "pipewire.ucred.uid", "%d", ucred->uid);
 | 
			
		||||
		pw_properties_setf(properties, "pipewire.ucred.gid", "%d", ucred->gid);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this->properties = properties;
 | 
			
		||||
 | 
			
		||||
	if (user_data_size > 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue