mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Fix for argv for setuid scripts (Solaris patch 115-CR6934836)
This change is pulled from here: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/115-CR6934836.patch Unfortunately there is no publicly available documentation on what this does or why it was needed. We just have to assume the Solaris people knew what they were doing. ksh2020 upstreamed this too (as well as all the other Solaris patches applied here).
This commit is contained in:
		
							parent
							
								
									3f15067272
								
							
						
					
					
						commit
						bae02c39b6
					
				
					 3 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -102,6 +102,8 @@ struct sh_scoped
 | 
				
			||||||
	char		**otrapcom;
 | 
						char		**otrapcom;
 | 
				
			||||||
	void		*timetrap;
 | 
						void		*timetrap;
 | 
				
			||||||
	struct Ufunction *real_fun;	/* current 'function name' function */
 | 
						struct Ufunction *real_fun;	/* current 'function name' function */
 | 
				
			||||||
 | 
						int             repl_index;
 | 
				
			||||||
 | 
						char            *repl_arg;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct limits
 | 
					struct limits
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1339,6 +1339,7 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
 | 
				
			||||||
	sh_onoption(SH_MULTILINE);
 | 
						sh_onoption(SH_MULTILINE);
 | 
				
			||||||
	if(argc>0)
 | 
						if(argc>0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
							int dolv_index;
 | 
				
			||||||
		/* check for restricted shell */
 | 
							/* check for restricted shell */
 | 
				
			||||||
		if(type&SH_TYPE_RESTRICTED)
 | 
							if(type&SH_TYPE_RESTRICTED)
 | 
				
			||||||
			sh_onoption(SH_RESTRICTED);
 | 
								sh_onoption(SH_RESTRICTED);
 | 
				
			||||||
| 
						 | 
					@ -1355,7 +1356,10 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
 | 
				
			||||||
			sh_done(shp,0);
 | 
								sh_done(shp,0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		opt_info.disc = 0;
 | 
							opt_info.disc = 0;
 | 
				
			||||||
		shp->st.dolv=argv+(argc-1)-shp->st.dolc;
 | 
							dolv_index = (argc - 1) - shp->st.dolc;
 | 
				
			||||||
 | 
							shp->st.dolv = argv + dolv_index;
 | 
				
			||||||
 | 
							shp->st.repl_index = dolv_index;
 | 
				
			||||||
 | 
							shp->st.repl_arg = argv[dolv_index];
 | 
				
			||||||
		shp->st.dolv[0] = argv[0];
 | 
							shp->st.dolv[0] = argv[0];
 | 
				
			||||||
		if(shp->st.dolc < 1)
 | 
							if(shp->st.dolc < 1)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -267,6 +267,8 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
 | 
				
			||||||
					 * try to undo effect of solaris 2.5+
 | 
										 * try to undo effect of solaris 2.5+
 | 
				
			||||||
					 * change for argv for setuid scripts
 | 
										 * change for argv for setuid scripts
 | 
				
			||||||
					 */
 | 
										 */
 | 
				
			||||||
 | 
										if(shp->st.repl_index > 0)
 | 
				
			||||||
 | 
											av[shp->st.repl_index] = shp->st.repl_arg;
 | 
				
			||||||
					if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (name = nv_getval(L_ARGNOD)) && (!((type = sh_type(cp = name)) & SH_TYPE_SH)))
 | 
										if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (name = nv_getval(L_ARGNOD)) && (!((type = sh_type(cp = name)) & SH_TYPE_SH)))
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						av[0] = (type & SH_TYPE_LOGIN) ? cp : path_basename(cp);
 | 
											av[0] = (type & SH_TYPE_LOGIN) ? cp : path_basename(cp);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue