~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hed/libs/credential/NSSGetPassword.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-11-29 13:39:10 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20131129133910-altaxrfowczzl2ev
Tags: 4.0.0-1
4.0.0 Release (Closes: #715131) (LP: #1049798)

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    int infd  = fileno(input);
67
67
    int isTTY = isatty(infd);
68
68
#endif
69
 
    char phrase[200] = {'\0'};      /* ensure EOF doesn't return junk */
 
69
    char phrase[200] = {'\0'};      // ensure EOF doesn't return junk
70
70
 
71
71
    for (;;) {
72
 
      /* Prompt for password */
 
72
      // Prompt for password
73
73
      if (isTTY) {
74
74
        fprintf(output, "%s", prompt);
75
75
        fflush (output);
83
83
        echoOn(infd);
84
84
      }
85
85
 
86
 
      /* stomp on newline */
 
86
      // stomp on newline
87
87
      phrase[PORT_Strlen(phrase)-1] = 0;
88
88
 
89
 
      /* Validate password */
 
89
      // Validate password 
90
90
      if (!(*ok)(phrase)) {
91
 
        /* Not weird enough */
 
91
        // Not weird enough 
92
92
        if (!isTTY) return 0;
93
93
        fprintf(output, "Password must be at least 8 characters long with one or more\n");
94
94
        fprintf(output, "non-alphabetic characters\n");
99
99
    return NULL;
100
100
  }
101
101
 
 
102
  /*
102
103
  static PRBool CheckPassword(char *cp) {
103
104
    int len;
104
105
    char *end;
112
113
      unsigned char ch = *cp++;
113
114
      if (!((ch >= 'A') && (ch <= 'Z')) &&
114
115
          !((ch >= 'a') && (ch <= 'z'))) {
115
 
        /* pass phrase has at least one non alphabetic in it */
 
116
        // pass phrase has at least one non alphabetic in it 
116
117
        return PR_TRUE;
117
118
      }
118
119
    }
119
120
    return PR_FALSE;
120
121
  }
 
122
  */
121
123
 
122
124
  static PRBool BlindCheckPassword(char *cp) {
123
125
    if (cp != NULL) {
126
128
    return PR_FALSE;
127
129
  }
128
130
 
129
 
  /* Get a password from the input terminal, without echoing */
 
131
  // Get a password from the input terminal, without echoing 
130
132
#if defined(_WINDOWS)
131
133
  static char * quiet_fgets (char *buf, int length, FILE *input) {
132
134
    int c;
133
135
    char *end = buf;
134
136
 
135
 
    /* fflush (input); */
 
137
    // fflush (input); 
136
138
    memset (buf, 0, length);
137
139
 
138
140
    if (!isatty(fileno(input))) {
141
143
 
142
144
    while (1) {
143
145
#if defined (_WIN32_WCE)
144
 
      c = getchar();      /* gets a character from stdin */
 
146
      c = getchar();      // gets a character from stdin 
145
147
#else
146
 
      c = getch();        /* getch gets a character from the console */
 
148
      c = getch();        // getch gets a character from the console 
147
149
#endif
148
150
      if (c == '\b') {
149
151
      if (end > buf)
228
230
    return NULL;
229
231
 
230
232
  }
 
233
 
231
234
}