Exemple #1
0
/****************************************************************************
an enhanced crypt for OSF1
****************************************************************************/
static char *osf1_bigcrypt(char *password, char *salt1)
{
	static char result[AUTH_MAX_PASSWD_LENGTH] = "";
	char *p1;
	char *p2 = password;
	char salt[3];
	int i;
	int parts = strlen(password) / AUTH_CLEARTEXT_SEG_CHARS;
	if (strlen(password) % AUTH_CLEARTEXT_SEG_CHARS)
		parts++;

	StrnCpy(salt, salt1, 2);
	StrnCpy(result, salt1, 2);
	result[2] = '\0';

	for (i = 0; i < parts; i++) {
		p1 = crypt(p2, salt);
		strncat(result, p1 + 2,
			AUTH_MAX_PASSWD_LENGTH - strlen(p1 + 2) - 1);
		StrnCpy(salt, &result[2 + i * AUTH_CIPHERTEXT_SEG_CHARS], 2);
		p2 += AUTH_CLEARTEXT_SEG_CHARS;
	}

	return (result);
}
Exemple #2
0
void fill_share_2(SHARE_INFO_1 *sh1, int snum)
{
	StrnCpy(sh1[0].shi1_netname, "tmp", 13);
	sh1[0].shi1_type = STYPE_DISKTREE;
	sh1[0].shi1_remark = "some weird comment";

	lp_comment(snum);
	lp_pathname(snum);
	StrnCpy(p, lp_servicename(snum), 13);

	type = STYPE_DISKTREE;
	if (lp_print_ok(snum))
		type = STYPE_PRINTQ;
	if (strequal("IPC$", lp_servicename(snum)))
		type = STYPE_IPC;
	lp_comment(snum);
#endif

void fill_share_1(SHARE_INFO_1 *sh1, int snum)
{
	StrnCpy(sh1->shi1_netname, lp_servicename(snum), 13);
	sh1->shi1_remark = lp_comment(snum);
	sh1->shi1_type = STYPE_DISKTREE;
	if (lp_print_ok(snum))
		sh1->shi1_type = STYPE_PRINTQ;
	if (strequal("IPC$", lp_servicename(snum)))
		sh1->shi1_type = STYPE_IPC;
}
/****************************************************************************
Build the print command in the supplied buffer. This means getting the
print command for the service and inserting the printer name and the
print file name. Return NULL on error, else the passed buffer pointer.
****************************************************************************/
static char *build_print_command(int cnum, char *command, char *syscmd, char *filename1)
{
  int snum = SNUM(cnum);
  char *tstr;
  pstring filename;
  
  /* get the print command for the service. */
  tstr = command;
  if (!syscmd || !tstr) {
    DEBUG(0,("No print command for service `%s'\n", SERVICE(snum)));
    return (NULL);
  }

  /* copy the command into the buffer for extensive meddling. */
  StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
  
  /* look for "%s" in the string. If there is no %s, we cannot print. */   
  if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
    DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
  }
  
  if (strstr(syscmd,"%s")) {
    int iOffset = PTR_DIFF(strstr(syscmd, "%s"),syscmd);
    
    /* construct the full path for the filename, shouldn't be necessary unless
       the subshell causes a "cd" to be executed.
       Only use the full path if there isn't a / preceding the %s */
    if (iOffset==0 || syscmd[iOffset-1] != '/') {
      StrnCpy(filename,Connections[cnum].connectpath,sizeof(filename)-1);
      trim_string(filename,"","/");
      pstrcat(filename,"/");
      pstrcat(filename,filename1);
    }
    else
      pstrcpy(filename,filename1);
    
    string_sub(syscmd, "%s", filename);
  }
  
  string_sub(syscmd, "%f", filename1);
  
  /* Does the service have a printername? If not, make a fake and empty    */
  /* printer name. That way a %p is treated sanely if no printer */
  /* name was specified to replace it. This eventuality is logged.         */
  tstr = PRINTERNAME(snum);
  if (tstr == NULL || tstr[0] == '\0') {
    DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
    tstr = SERVICE(snum);
  }
  
  string_sub(syscmd, "%p", tstr);
  
  standard_sub(cnum,syscmd);
  
  return (syscmd);
}
/****************************************************************************
  parse a lpq line for the plp printing system
  Bertrand Wallrich <*****@*****.**>

redone by tridge. Here is a sample queue:

Local  Printer 'lp2' (fjall):
  Printing (started at Jun 15 13:33:58, attempt 1).
    Rank Owner       Pr Opt  Job Host        Files           Size     Date
  active tridge      X  -    6   fjall       /etc/hosts      739      Jun 15 13:33
     3rd tridge      X  -    7   fjall       /etc/hosts      739      Jun 15 13:33

****************************************************************************/
static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
{
  fstring tok[11];
  int count=0;

  /* handle the case of "(standard input)" as a filename */
  string_sub(line,"stdin","STDIN");
  string_sub(line,"(","\"");
  string_sub(line,")","\"");
  
  for (count=0; count<11 && next_token(&line,tok[count],NULL); count++) ;

  /* we must get 11 tokens */
  if (count < 11)
    return(False);

  /* the first must be "active" or begin with an integer */
  if (strcmp(tok[0],"active") && !isdigit(tok[0][0]))
    return(False);

  /* the 5th and 8th must be integer */
  if (!isdigit(*tok[4]) || !isdigit(*tok[7])) 
    return(False);

  /* if the fname contains a space then use STDIN */
  if (strchr(tok[6],' '))
    fstrcpy(tok[6],"STDIN");

  /* only take the last part of the filename */
  {
    fstring tmp;
    char *p = strrchr(tok[6],'/');
    if (p)
      {
        fstrcpy(tmp,p+1);
        fstrcpy(tok[6],tmp);
      }
  }


  buf->job = atoi(tok[4]);

  buf->size = atoi(tok[7]);
  if (strchr(tok[7],'K'))
    buf->size *= 1024;
  if (strchr(tok[7],'M'))
    buf->size *= 1024*1024;

  buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED;
  buf->priority = 0;
  buf->time = time(NULL);
  StrnCpy(buf->user,tok[1],sizeof(buf->user)-1);
  StrnCpy(buf->file,tok[6],sizeof(buf->file)-1);
  return(True);
}
/****************************************************************************
parse a lpq line

here is an example of lpq output under qnx
Spooler: /qnx/spooler, on node 1
Printer: txt        (ready) 
0000:     root	[job #1    ]   active 1146 bytes	/etc/profile
0001:     root	[job #2    ]    ready 2378 bytes	/etc/install
0002:     root	[job #3    ]    ready 1146 bytes	-- standard input --
****************************************************************************/
static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
{
  fstring tok[7];
  int count=0;

  DEBUG(0,("antes [%s]\n", line));

  /* handle the case of "-- standard input --" as a filename */
  string_sub(line,"standard input","STDIN");
  DEBUG(0,("despues [%s]\n", line));
  string_sub(line,"-- ","\"");
  string_sub(line," --","\"");
  DEBUG(0,("despues 1 [%s]\n", line));

  string_sub(line,"[job #","");
  string_sub(line,"]","");
  DEBUG(0,("despues 2 [%s]\n", line));

  
  
  for (count=0; count<7 && next_token(&line,tok[count],NULL); count++) ;

  /* we must get 7 tokens */
  if (count < 7)
    return(False);

  /* the 3rd and 5th columns must be integer */
  if (!isdigit(*tok[2]) || !isdigit(*tok[4])) return(False);

  /* only take the last part of the filename */
  {
    fstring tmp;
    char *p = strrchr(tok[6],'/');
    if (p)
      {
	fstrcpy(tmp,p+1);
	fstrcpy(tok[6],tmp);
      }
  }
	

  buf->job = atoi(tok[2]);
  buf->size = atoi(tok[4]);
  buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
  buf->priority = 0;
  buf->time = time(NULL);
  StrnCpy(buf->user,tok[1],sizeof(buf->user)-1);
  StrnCpy(buf->file,tok[6],sizeof(buf->file)-1);
  return(True);
}
Exemple #6
0
/****************************************************************************
interpret a node status response
****************************************************************************/
static void _interpret_node_status(char *p, char *master,char *rname)
{
  int numnames = CVAL(p,0);
  DEBUG(1,("received %d names\n",numnames));

  if (rname) *rname = 0;
  if (master) *master = 0;

  p += 1;
  while (numnames--)
    {
      char qname[17];
      int type;
      fstring flags;
      int i;
      *flags = 0;
      StrnCpy(qname,p,15);
      type = CVAL(p,15);
      p += 16;

      fstrcat(flags, (p[0] & 0x80) ? "<GROUP> " : "        ");
      if ((p[0] & 0x60) == 0x00) fstrcat(flags,"B ");
      if ((p[0] & 0x60) == 0x20) fstrcat(flags,"P ");
      if ((p[0] & 0x60) == 0x40) fstrcat(flags,"M ");
      if ((p[0] & 0x60) == 0x60) fstrcat(flags,"H ");
      if (p[0] & 0x10) fstrcat(flags,"<DEREGISTERING> ");
      if (p[0] & 0x08) fstrcat(flags,"<CONFLICT> ");
      if (p[0] & 0x04) fstrcat(flags,"<ACTIVE> ");
      if (p[0] & 0x02) fstrcat(flags,"<PERMANENT> ");

      if (master && !*master && type == 0x1d) {
	StrnCpy(master,qname,15);
	trim_string(master,NULL," ");
      }

      if (rname && !*rname && type == 0x20 && !(p[0]&0x80)) {
	StrnCpy(rname,qname,15);
	trim_string(rname,NULL," ");
      }
      
      for (i = strlen( qname) ; --i >= 0 ; ) {
	if (!isprint((int)qname[i])) qname[i] = '.';
      }
      DEBUG(1,("\t%-15s <%02x> - %s\n",qname,type,flags));
      p+=2;
    }
  DEBUG(1,("num_good_sends=%d num_good_receives=%d\n",
	       IVAL(p,20),IVAL(p,24)));
}
Exemple #7
0
/**
  Function to take the destination path and target file name to generate the full destination path.

  @param[in] DestPath           A pointer to the destination file path string.
  @param[out] FullDestPath      A pointer to the full destination path string.
  @param[in] FileName           Name string of  the targe file.

  @retval SHELL_SUCCESS             the files were all moved.
  @retval SHELL_INVALID_PARAMETER   a parameter was invalid
  @retval SHELL_OUT_OF_RESOURCES    a memory allocation failed
**/
EFI_STATUS
EFIAPI
CreateFullDestPath(
  IN CONST CHAR16 **DestPath,
  OUT CHAR16      **FullDestPath, 
  IN CONST CHAR16 *FileName
  )
{
  UINTN Size;
  if (FullDestPath == NULL || FileName == NULL || DestPath == NULL || *DestPath == NULL){
    return (EFI_INVALID_PARAMETER);
  }

  Size = StrSize(*DestPath) + StrSize(FileName);

  *FullDestPath = AllocateZeroPool(Size);
  if (*FullDestPath == NULL){
    return (EFI_OUT_OF_RESOURCES);
  }

  StrnCpy(*FullDestPath, *DestPath, Size / sizeof(CHAR16) - 1);
  if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {
    StrnCat(*FullDestPath, L"\\",Size / sizeof(CHAR16) - 1 - StrLen(*FullDestPath));
  }
  StrnCat(*FullDestPath, FileName, Size / sizeof(CHAR16) - 1 - StrLen(*FullDestPath));

  return (EFI_SUCCESS);
}
Exemple #8
0
STATIC
UINT32
FatHashLongName (
  IN CHAR16   *LongNameString
  )
/*++

Routine Description:

  Get hash value for long name.

Arguments:

  LongNameString        - The long name string to be hashed.

Returns:

  HashValue.

--*/
{
  UINT32  HashValue;
  CHAR16  UpCasedLongFileName[EFI_PATH_STRING_LENGTH];
  StrnCpy (UpCasedLongFileName, LongNameString, EFI_PATH_STRING_LENGTH - 1);
  UpCasedLongFileName[EFI_PATH_STRING_LENGTH - 1] = L'\0';
  FatStrUpr (UpCasedLongFileName);
  gBS->CalculateCrc32 (UpCasedLongFileName, StrSize (UpCasedLongFileName), &HashValue);
  return (HashValue & HASH_TABLE_MASK);
}
Exemple #9
0
Var *FindVar(char const *str, int create)
{
    register int h;
    register Var *v;
    register Var *prev;

    h = HashVal(str) % VAR_HASH_SIZE;
    v = VHashTbl[h];
    prev = NULL;

    while(v) {
	if (! StrinCmp(str, v->name, VAR_NAME_LEN)) return v;
	prev = v;
	v = v-> next;
    }
    if (!create) return v;

/* Create the variable */
    v = NEW(Var);
    if (!v) return v;
    v->next = NULL;
    v->v.type = INT_TYPE;
    v->v.v.val = 0;
    v->preserve = 0;
    StrnCpy(v->name, str, VAR_NAME_LEN);

    if (prev) prev->next = v; else VHashTbl[h] = v;
    return v;
}
Exemple #10
0
uint16 _api_DosNetServerGetInfo(PCONN_HND phnd, io_struct * ps,
				uint16 sLevel,
				RCVBUF pbBuffer,
				RCVBUFLEN cbBuffer, uint16 *pcTotalAvail)
{
	SERVER_INFO_1 sv1;

	DEBUG(10,("DosNetServerGetInfo: %d buf %d\n",
				sLevel, cbBuffer));
	StrnCpy(sv1.sv1_name, local_machine, 16);
	strupper(sv1.sv1_name);
	sv1.sv1_version_major = 4;
	sv1.sv1_version_minor = 1;
	sv1.sv1_type = SV_TYPE_NT;

	sv1.sv1_comment_or_master_browser = string_truncate(lp_serverstring(),
					MAX_SERVER_STRING_LENGTH);

	switch (sLevel)
	{
		case 1:
		{
			if (!io_SERVER_INFO_1("sv1", ps, 0, &sv1,
						PARSE_SCALARS))
				return NERR_BufTooSmall;

			if (!io_SERVER_INFO_1("sv1", ps, 0, &sv1,
						PARSE_OFFSETS))
				return NERR_BufTooSmall;
			return ERRsuccess;
		}
	}
	return ERRunknownlevel;
}
Exemple #11
0
void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work)
{
    pstring outbuf;
    char *p;

    work->needannounce = True;

    DEBUG(3,("broadcast_announce_request: sending announce request for workgroup %s \
to subnet %s\n", work->work_group, subrec->subnet_name));

    memset(outbuf,'\0',sizeof(outbuf));
    p = outbuf;
    SCVAL(p,0,ANN_AnnouncementRequest);
    p++;

    SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */
    p++;
    StrnCpy(p,global_myname,15);
    strupper(p);
    p = skip_string(p,1);

    send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
                  global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip,
                  subrec->myip, DGRAM_PORT);
}
Exemple #12
0
static void send_lm_announcement(struct subnet_record *subrec, int announce_type,
                                 char *from_name, char *to_name, int to_type, struct in_addr to_ip,
                                 time_t announce_interval,
                                 char *server_name, int server_type, char *server_comment)
{
    pstring outbuf;
    char *p=outbuf;

    memset(outbuf,'\0',sizeof(outbuf));

    SSVAL(p,0,announce_type);
    SIVAL(p,2,server_type & ~SV_TYPE_LOCAL_LIST_ONLY);
    SCVAL(p,6,lp_major_announce_version()); /* Major version. */
    SCVAL(p,7,lp_minor_announce_version()); /* Minor version. */
    SSVAL(p,8,announce_interval);            /* In seconds - according to spec. */

    p += 10;
    StrnCpy(p,server_name,15);
    strupper(p);
    p = skip_string(p,1);
    pstrcpy(p,server_comment);
    p = skip_string(p,1);

    send_mailslot(False,LANMAN_MAILSLOT, outbuf, PTR_DIFF(p,outbuf),
                  from_name, 0x0, to_name, to_type, to_ip, subrec->myip,
                  DGRAM_PORT);
}
Exemple #13
0
/*******************************************************************
 return the DNS name of the client 
 ******************************************************************/
char *
client_name (int fd)
{
    struct sockaddr sa;
    struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
    unsigned int length = sizeof (sa);
    static pstring name_buf;
    struct hostent *hp;
    static int last_fd = -1;

    if (global_client_name_done && last_fd == fd)
        return name_buf;

    last_fd = fd;
    global_client_name_done = False;

    pstrcpy (name_buf, "UNKNOWN");

    if (fd == -1)
    {
        return name_buf;
    }

    if (getpeername (fd, &sa, &length) < 0)
    {
        DEBUG (0, ("getpeername failed. Error was %s\n", unix_error_string (errno)));
        return name_buf;
    }

    /* Look up the remote host name. */
    if ((hp = gethostbyaddr ((char *) &sockin->sin_addr, sizeof (sockin->sin_addr), AF_INET)) == 0)
    {
        DEBUG (1, ("Gethostbyaddr failed for %s\n", client_addr (fd)));
        StrnCpy (name_buf, client_addr (fd), sizeof (name_buf) - 1);
    }
    else
    {
        StrnCpy (name_buf, (char *) hp->h_name, sizeof (name_buf) - 1);
        if (!matchname (name_buf, sockin->sin_addr))
        {
            DEBUG (0, ("Matchname failed on %s %s\n", name_buf, client_addr (fd)));
            pstrcpy (name_buf, "UNKNOWN");
        }
    }
    global_client_name_done = True;
    return name_buf;
}
Exemple #14
0
/**
  sets a list of all Shell-Guid-based environment variables.

  @param Environment        Points to a NULL-terminated array of environment
                            variables with the format 'x=y', where x is the
                            environment variable name and y is the value.

  @retval EFI_SUCCESS       The command executed successfully.
  @retval EFI_INVALID_PARAMETER The parameter is invalid.
  @retval EFI_OUT_OF_RESOURCES Out of resources.

  @sa SetEnvironmentVariableList
**/
EFI_STATUS
EFIAPI
SetEnvironmentVariables(
    IN CONST CHAR16 **Environment
)
{
    CONST CHAR16  *CurrentString;
    UINTN         CurrentCount;
    ENV_VAR_LIST  *VarList;
    ENV_VAR_LIST  *Node;
    UINTN         NewSize;

    VarList = NULL;

    if (Environment == NULL) {
        return (EFI_INVALID_PARAMETER);
    }

    //
    // Build a list identical to the ones used for get/set list functions above
    //
    for ( CurrentCount = 0
                         ;
            ; CurrentCount++
        ) {
        CurrentString = Environment[CurrentCount];
        if (CurrentString == NULL) {
            break;
        }
        ASSERT(StrStr(CurrentString, L"=") != NULL);
        Node = AllocateZeroPool(sizeof(ENV_VAR_LIST));
        ASSERT(Node != NULL);
        Node->Key = AllocateZeroPool((StrStr(CurrentString, L"=") - CurrentString + 1) * sizeof(CHAR16));
        ASSERT(Node->Key != NULL);
        StrnCpy(Node->Key, CurrentString, StrStr(CurrentString, L"=") - CurrentString);
        NewSize = StrSize(CurrentString);
        NewSize -= StrLen(Node->Key) - 1;
        Node->Val = AllocateZeroPool(NewSize);
        ASSERT(Node->Val != NULL);
        StrCpy(Node->Val, CurrentString + StrLen(Node->Key) + 1);
        Node->Atts = EFI_VARIABLE_BOOTSERVICE_ACCESS;

        if (VarList == NULL) {
            VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
            ASSERT(VarList != NULL);
            InitializeListHead(&VarList->Link);
        }
        InsertTailList(&VarList->Link, &Node->Link);

    } // for loop

    //
    // set this new list as the set of all environment variables.
    // this function also frees the memory and deletes all pre-existing
    // shell-guid based environment variables.
    //
    return (SetEnvironmentVariableList(&VarList->Link));
}
Exemple #15
0
struct passwd *Get_Pwnam(char *user,BOOL allow_change)
{
  fstring user2;
  int last_char;
  int usernamelevel = lp_usernamelevel();

  struct passwd *ret;  

  if (!user || !(*user))
    return(NULL);

  StrnCpy(user2,user,sizeof(user2)-1);

  if (!allow_change) {
    user = &user2[0];
  }

  ret = _Get_Pwnam(user);
  if (ret)
    return(ret);

  strlower(user);
  ret = _Get_Pwnam(user);
  if (ret)
    return(ret);

  strupper(user);
  ret = _Get_Pwnam(user);
  if (ret)
    return(ret);

  /* Try with first letter capitalised. */
  if (strlen(user) > 1)
    strlower(user+1);  
  ret = _Get_Pwnam(user);
  if (ret)
    return(ret);

  /* try with last letter capitalised */
  strlower(user);
  last_char = strlen(user)-1;
  user[last_char] = toupper(user[last_char]);
  ret = _Get_Pwnam(user);
  if (ret)
    return(ret);

  /* Try all combinations up to usernamelevel. */
  strlower(user);
  ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
  if (ret)
    return(ret);

  if (allow_change)
    fstrcpy(user,user2);

  return(NULL);
}
Exemple #16
0
static void fixtarname(char *tptr, const char *fp, size_t l)
{
	/* add a '.' to start of file name, convert from ugly dos \'s in path
	 * to lovely unix /'s :-} */
	*tptr++='.';
	l--;

	StrnCpy(tptr, fp, l-1);
	string_replace(tptr, '\\', '/');
}
Exemple #17
0
EFI_STATUS
GenerateDeviceDescriptionName (
  IN  EFI_HANDLE  Handle,
  IN OUT CHAR16*  Description
  )
{
  EFI_STATUS                        Status;
  EFI_COMPONENT_NAME_PROTOCOL*      ComponentName2Protocol;
  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
  EFI_DEVICE_PATH_PROTOCOL*         DevicePathProtocol;
  CHAR16*                           DriverName;
  CHAR16*                           DevicePathTxt;
  EFI_DEVICE_PATH*                  DevicePathNode;

  ComponentName2Protocol = NULL;
  Status = gBS->HandleProtocol (Handle, &gEfiComponentName2ProtocolGuid, (VOID **)&ComponentName2Protocol);
  if (!EFI_ERROR(Status)) {
    //TODO: Fixme. we must find the best langague
    Status = ComponentName2Protocol->GetDriverName (ComponentName2Protocol,"en",&DriverName);
    if (!EFI_ERROR(Status)) {
      StrnCpy (Description, DriverName, BOOT_DEVICE_DESCRIPTION_MAX);
    }
  }

  if (EFI_ERROR(Status)) {
    // Use the lastest non null entry of the Device path as a description
    Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);
    if (EFI_ERROR(Status)) {
      return Status;
    }

    // Convert the last non end-type Device Path Node in text for the description
    DevicePathNode = GetLastDevicePathNode (DevicePathProtocol);
    Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
    ASSERT_EFI_ERROR(Status);
    DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (DevicePathNode, TRUE, TRUE);
    StrnCpy (Description, DevicePathTxt, BOOT_DEVICE_DESCRIPTION_MAX);
    FreePool (DevicePathTxt);
  }

  return EFI_SUCCESS;
}
/****************************************************************************
parse a lpq line

here is an example of "lpstat -o dcslw" output under sysv

dcslw-896               tridge            4712   Dec 20 10:30:30 on dcslw
dcslw-897               tridge            4712   Dec 20 10:30:30 being held

****************************************************************************/
static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
{
  fstring tok[9];
  int count=0;
  char *p;

  /* handle the dash in the job id */
  string_sub(line,"-"," ");
  
  for (count=0; count<9 && next_token(&line,tok[count],NULL); count++) ;

  /* we must get 7 tokens */
  if (count < 7)
    return(False);

  /* the 2nd and 4th, 6th columns must be integer */
  if (!isdigit(*tok[1]) || !isdigit(*tok[3])) return(False);
  if (!isdigit(*tok[5])) return(False);

  /* if the user contains a ! then trim the first part of it */  
  if ((p=strchr(tok[2],'!')))
    {
      fstring tmp;
      fstrcpy(tmp,p+1);
      fstrcpy(tok[2],tmp);
    }
    

  buf->job = atoi(tok[1]);
  buf->size = atoi(tok[3]);
  if (count > 7 && strequal(tok[7],"on"))
    buf->status = LPQ_PRINTING;
  else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held"))
    buf->status = LPQ_PAUSED;
  else
    buf->status = LPQ_QUEUED;
  buf->priority = 0;
  buf->time = EntryTime(tok, 4, count, 7);
  StrnCpy(buf->user,tok[2],sizeof(buf->user)-1);
  StrnCpy(buf->file,tok[2],sizeof(buf->file)-1);
  return(True);
}
Exemple #19
0
static void check_for_pipe(char *fname)
{
	/* special case of pipe opens */
	char s[10];
	StrnCpy(s,fname,sizeof(s)-1);
	strlower(s);
	if (strstr(s,"pipe/")) {
		DEBUG(3,("Rejecting named pipe open for %s\n",fname));
		unix_ERR_class = ERRSRV;
		unix_ERR_code = ERRaccess;
		unix_ERR_ntstatus = NT_STATUS_ACCESS_DENIED;
	}
}
Exemple #20
0
/*
 * This implements the X/Open SMB password encryption
 * It takes a password, a 8 byte "crypt key" and puts 24 bytes of
 * encrypted password into p24 */
void
SMBencrypt(uchar * passwd, uchar * c8, uchar * p24)
{
    uchar p14[15], p21[21];

    memset(p21, '\0', 21);
    memset(p14, '\0', 14);
    StrnCpy((char *) p14, (char *) passwd, 14);

    strupper((char *) p14);
    E_P16(p14, p21);
    E_P24(p21, c8, p24);
}
Exemple #21
0
/****************************************************************************
a wrapper for getpwnam() that tries with all lower and all upper case 
if the initial name fails. Also tried with first letter capitalised
****************************************************************************/
struct passwd *
Get_Pwnam (const char *a_user)
{
    fstring user;
    int last_char;
    int usernamelevel = lp_usernamelevel ();

    struct passwd *ret;

    if (!a_user || !(*a_user))
        return (NULL);

    StrnCpy (user, a_user, sizeof (user) - 1);

    ret = _Get_Pwnam (user);
    if (ret)
        return (ret);

    strlower (user);
    ret = _Get_Pwnam (user);
    if (ret)
        return (ret);

    strupper (user);
    ret = _Get_Pwnam (user);
    if (ret)
        return (ret);

    /* try with first letter capitalised */
    if (strlen (user) > 1)
        strlower (user + 1);
    ret = _Get_Pwnam (user);
    if (ret)
        return (ret);

    /* try with last letter capitalised */
    strlower (user);
    last_char = strlen (user) - 1;
    user[last_char] = toupper (user[last_char]);
    ret = _Get_Pwnam (user);
    if (ret)
        return (ret);

    /* try all combinations up to usernamelevel */
    strlower (user);
    ret = uname_string_combinations (user, _Get_Pwnam, usernamelevel);
    if (ret)
        return (ret);

    return (NULL);
}
Exemple #22
0
/**
  Split a string with specified separator and save the substring to a list.

  @param[in]    String       The pointer of the input string.
  @param[in]    Separator    The specified separator.

  @return The pointer of headnode of ARG_LIST.

**/
ARG_LIST *
SplitStrToList (
  IN CONST CHAR16    *String,
  IN CHAR16          Separator
  )
{
  CHAR16      *Str;
  CHAR16      *ArgStr;
  ARG_LIST    *ArgList;
  ARG_LIST    *ArgNode;

  if (*String == L'\0') {
    return NULL;
  }

  //
  // Copy the CONST string to a local copy.
  //
  Str     = (CHAR16 *) AllocateZeroPool (StrSize (String));
  ASSERT (Str != NULL);
  Str     = StrnCpy (Str, String, StrLen (String));
  ArgStr  = Str;

  //
  // init a node for the list head.
  //
  ArgNode = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
  ASSERT (ArgNode != NULL);
  ArgList = ArgNode;

  //
  // Split the local copy and save in the list node.
  //
  while (*Str != L'\0') {
    if (*Str == Separator) {
      *Str          = L'\0';
      ArgNode->Arg  = ArgStr;
      ArgStr        = Str + 1;
      ArgNode->Next = (ARG_LIST *) AllocateZeroPool (sizeof (ARG_LIST));
      ASSERT (ArgNode->Next != NULL);
      ArgNode = ArgNode->Next;
    }

    Str++;
  }

  ArgNode->Arg  = ArgStr;
  ArgNode->Next = NULL;

  return ArgList;
}
Exemple #23
0
/**
  Get a human readable name for an image.
  The following methods will be tried orderly:
    1. Image PDB
    2. FFS UI section
    3. Image GUID

  @param[in] DriverInfo Pointer to memory profile driver info.

  @post The resulting Unicode name string is stored in the mNameString global array.

**/
VOID
GetDriverNameString (
 IN MEMORY_PROFILE_DRIVER_INFO  *DriverInfo
 )
{
  EFI_STATUS                  Status;
  CHAR8                       *PdbFileName;
  CHAR16                      *NameString;
  UINTN                       StringSize;

  //
  // Method 1: Get the name string from image PDB
  //
  if ((DriverInfo->ImageBase != 0) && (DriverInfo->FileType != EFI_FV_FILETYPE_SMM) && (DriverInfo->FileType != EFI_FV_FILETYPE_SMM_CORE)) {
    PdbFileName = PeCoffLoaderGetPdbPointer ((VOID *) (UINTN) DriverInfo->ImageBase);

    if (PdbFileName != NULL) {
      GetShortPdbFileName (PdbFileName, mNameString);
      return;
    }
  }

  if (!CompareGuid (&DriverInfo->FileName, &gZeroGuid)) {
    //
    // Try to get the image's FFS UI section by image GUID
    //
    NameString = NULL;
    StringSize = 0;
    Status = GetSectionFromAnyFv (
              &DriverInfo->FileName,
              EFI_SECTION_USER_INTERFACE,
              0,
              (VOID **) &NameString,
              &StringSize
              );
    if (!EFI_ERROR (Status)) {
      //
      // Method 2: Get the name string from FFS UI section
      //
      StrnCpy (mNameString, NameString, PROFILE_NAME_STRING_LENGTH);
      mNameString[PROFILE_NAME_STRING_LENGTH] = 0;
      FreePool (NameString);
      return;
    }
  }

  //
  // Method 3: Get the name string from image GUID
  //
  UnicodeSPrint (mNameString, sizeof (mNameString), L"%g", &DriverInfo->FileName);
}
Exemple #24
0
EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
  IN EFI_DEVICE_PATH            *OldDevicePath,
  IN CHAR16*                    FileName,
  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath
  )
{
  EFI_STATUS  Status;
  CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
  UINTN       BootFilePathSize;
  FILEPATH_DEVICE_PATH* EndingDevicePath;
  FILEPATH_DEVICE_PATH* FilePathDevicePath;
  EFI_DEVICE_PATH*  DevicePath;

  DevicePath = DuplicateDevicePath (OldDevicePath);

  EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);

  Print(L"File path of the %s: ", FileName);
  StrnCpy (BootFilePath, EndingDevicePath->PathName, BOOT_DEVICE_FILEPATH_MAX);
  Status = EditHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);
  if (EFI_ERROR(Status)) {
    return Status;
  }

  BootFilePathSize = StrSize(BootFilePath);
  if (BootFilePathSize == 2) {
    *NewDevicePath = NULL;
    return EFI_NOT_FOUND;
  }

  // Create the FilePath Device Path node
  FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
  if (NULL == FilePathDevicePath)
  {
    return EFI_INVALID_PARAMETER;
  }
  FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;
  FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;
  SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
  CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);

  // Generate the new Device Path by replacing the last node by the updated node
  SetDevicePathEndNode (EndingDevicePath);
  *NewDevicePath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FilePathDevicePath);
  FreePool(DevicePath);

  return EFI_SUCCESS;
}
/****************************************************************************
check if a username is valid
****************************************************************************/
BOOL user_ok(char *user,int snum)
{
  pstring valid, invalid;
  BOOL ret;

  StrnCpy(valid, lp_valid_users(snum), sizeof(pstring));
  StrnCpy(invalid, lp_invalid_users(snum), sizeof(pstring));

  string_sub(valid,"%S",lp_servicename(snum));
  string_sub(invalid,"%S",lp_servicename(snum));

  ret = !user_in_list(user,invalid);

  if (ret && valid && *valid)
    ret = user_in_list(user,valid);

  if (ret && lp_onlyuser(snum)) {
    char *user_list = lp_username(snum);
    string_sub(user_list,"%S",lp_servicename(snum));
    ret = user_in_list(user,user_list);
  }

  return(ret);
}
/****************************************************************************
add a name to the session users list
****************************************************************************/
void add_session_user(char *user)
{
  fstring suser;
  StrnCpy(suser,user,sizeof(suser)-1);

  if (!Get_Pwnam(suser,True)) return;

  if (suser && *suser && !in_list(suser,session_users,False))
    {
      if (strlen(suser) + strlen(session_users) + 2 >= sizeof(pstring))
	DEBUG(1,("Too many session users??\n"));
      else
	{
	  pstrcat(session_users," ");
	  pstrcat(session_users,suser);
	}
    }
}
Exemple #27
0
/**
 * Returns pointer to buffer containing directory part of the given path.
 * The returned string is either empty or ends with file separator character. 
 * Under Win32, if may also look like "C:", but in either case file name 
 * can be simply appended to it. The return buffer has 'extra' additional 
 * characters allocated past the end of the string. The function only 
 * returns NULL if input parameter is NULL or memory allocation fails. 
 */
Char * FILE_DirName(Str path, int extra) 
{
    Char * dir = NULL;
    ASSERT(path);
    ASSERT(extra >= 0);
    if (path) {
        size_t len = FILE_FilePart(path) - path;
        size_t size = len + 1;
        if (extra >= 0) size += extra;
        dir = MEM_NewArray(Char,size);

        /* copy portion of the source path */
        if (dir) {
            if (len > 0) StrnCpy(dir, path, len);
            dir[len] = 0;
        }
    }
    return dir;
}
/****************************************************************************
an enhanced crypt for Linux to handle password longer than 8 characters
****************************************************************************/
static int linux_bigcrypt(char *password,char *salt1, char *crypted)
{
#define LINUX_PASSWORD_SEG_CHARS 8
  char salt[3];
  int i;
  
  StrnCpy(salt,salt1,2);
  crypted +=2;
  
  for ( i=strlen(password); i > 0; i -= LINUX_PASSWORD_SEG_CHARS) {
    char * p = crypt(password,salt) + 2;
    if (strncmp(p, crypted, LINUX_PASSWORD_SEG_CHARS) != 0)
      return(0);
    password += LINUX_PASSWORD_SEG_CHARS;
    crypted  += strlen(p);
  }
  
  return(1);
}
Exemple #29
0
/*
   This implements the X/Open SMB password encryption
   It takes a password, a 8 byte "crypt key" and puts 24 bytes of 
   encrypted password into p24 */
void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24)
{
	uchar p14[15], p21[21];

	memset(p21,'\0',21);
	memset(p14,'\0',14);
	StrnCpy((char *)p14,(char *)passwd,14);

	strupper((char *)p14);
	E_P16(p14, p21); 

	SMBOWFencrypt(p21, c8, p24);

#ifdef DEBUG_PASSWORD
	DEBUG(100,("SMBencrypt: lm#, challenge, response\n"));
	dump_data(100, (char *)p21, 16);
	dump_data(100, (char *)c8, 8);
	dump_data(100, (char *)p24, 24);
#endif
}
Exemple #30
0
/** 
  Get the file name portion of the Pdb File Name.
  
  The portion of the Pdb File Name between the last backslash and
  either a following period or the end of the string is converted
  to Unicode and copied into UnicodeBuffer.  The name is truncated,
  if necessary, to ensure that UnicodeBuffer is not overrun.
  
  @param[in]  PdbFileName     Pdb file name.
  @param[out] UnicodeBuffer   The resultant Unicode File Name.
  
**/
VOID
GetShortPdbFileName (
  IN  CHAR8     *PdbFileName,
  OUT CHAR16    *UnicodeBuffer
  )
{
  UINTN IndexA;     // Current work location within an ASCII string.
  UINTN IndexU;     // Current work location within a Unicode string.
  UINTN StartIndex;
  UINTN EndIndex;

  ZeroMem (UnicodeBuffer, DXE_PERFORMANCE_STRING_LENGTH * sizeof (CHAR16));

  if (PdbFileName == NULL) {
    StrnCpy (UnicodeBuffer, L" ", 1);
  } else {
    StartIndex = 0;
    for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
      ;
    for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {
      if (PdbFileName[IndexA] == '\\') {
        StartIndex = IndexA + 1;
      }

      if (PdbFileName[IndexA] == '.') {
        EndIndex = IndexA;
      }
    }

    IndexU = 0;
    for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {
      UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];
      IndexU++;
      if (IndexU >= DXE_PERFORMANCE_STRING_LENGTH) {
        UnicodeBuffer[DXE_PERFORMANCE_STRING_LENGTH] = 0;
        break;
      }
    }
  }
}