Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mate-about-me: interact with passwd via /dev/ptmx #383

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

pyhalov
Copy link
Contributor

@pyhalov pyhalov commented Nov 6, 2018

No description provided.

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got these warnings ending in a build error on Debian Unstable:


mate-about-me-password.c: In function ‘spawn_passwd’:
mate-about-me-password.c:193:10: warning: implicit declaration of function ‘ptsname’; did you mean ‘ttyname’? [-Wimplicit-function-declaration]
   name = ptsname(pdialog->pty_m);
          ^~~~~~~
          ttyname
mate-about-me-password.c:193:8: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   name = ptsname(pdialog->pty_m);
        ^
mate-about-me-password.c:195:4: warning: implicit declaration of function ‘strlcpy’; did you mean ‘strncpy’? [-Wimplicit-function-declaration]
    strlcpy(slave_name, name, PTY_MAX_NAME);
    ^~~~~~~
    strncpy
mate-about-me-password.c:205:6: warning: implicit declaration of function ‘grantpt’ [-Wimplicit-function-declaration]
  if (grantpt(pdialog->pty_m) < 0) {
      ^~~~~~~
mate-about-me-password.c:210:6: warning: implicit declaration of function ‘unlockpt’; did you mean ‘unlinkat’? [-Wimplicit-function-declaration]
  if (unlockpt(pdialog->pty_m) < 0) {
      ^~~~~~~~
      unlinkat
mate-about-me-password.c:232:7: warning: implicit declaration of function ‘ioctl’ [-Wimplicit-function-declaration]
   if (ioctl(pdialog->pty_s,TIOCSCTTY, NULL) < 0) {
       ^~~~~
mate-about-me-password.c:232:28: error: ‘TIOCSCTTY’ undeclared (first use in this function)
   if (ioctl(pdialog->pty_s,TIOCSCTTY, NULL) < 0) {

@pyhalov
Copy link
Contributor Author

pyhalov commented Nov 7, 2018

@lukefromdc tried to follow linux man pages, however don't have a system to check compilation

@lukefromdc
Copy link
Member

Got another build error, this time


mate-about-me-password.c: In function ‘spawn_passwd’:
mate-about-me-password.c:240:28: error: ‘TIOCSCTTY’ undeclared (first use in this function)
   if (ioctl(pdialog->pty_s,TIOCSCTTY, NULL) < 0) {

@pyhalov pyhalov force-pushed the ptmx branch 2 times, most recently from dee8d5c to c5f7049 Compare November 10, 2018 18:54
@lukefromdc
Copy link
Member

Got another build error, maybe from a typo ?

mate-about-me-password.c: In function ‘spawn_passwd’:
mate-about-me-password.c:239:6: warning: implicit declaration of function ‘pipe2’; did you mean ‘pipe’? [-Wimplicit-function-declaration]
  if (pipe2(err_pipe, O_CLOEXEC) < 0) {
      ^~~~~
      pipe
mate-about-me-password.c:239:22: error: ‘O_CLOEXEC’ undeclared (first use in this function); did you mean ‘FD_CLOEXEC’?
  if (pipe2(err_pipe, O_CLOEXEC) < 0) {
                      ^~~~~~~~~
                      FD_CLOEXEC

@lukefromdc lukefromdc self-requested a review November 12, 2018 04:18
Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the last change, this now builds and runs on Debian Unstable, and I had no trouble changing a user password and changing it back

@lukefromdc lukefromdc requested a review from a team November 12, 2018 04:19
@lukefromdc
Copy link
Member

Note that I don't know enough about the handling of the *name variable set in line 196 and then initialized with name = ptsname(pty_m); to evaluate the memory handling here.

@pyhalov
Copy link
Contributor Author

pyhalov commented Nov 12, 2018

ptsname(3C) on OpenIndiana says:

      Upon successful completion, the function ptsname() returns a pointer to
       a string which is the name of the pseudo-terminal slave device. This
       value points to a static data area that is overwritten by each call to
       ptsname(). Upon failure, ptsname() returns NULL.

ptsname(3) on Linux says:

On success, ptsname() returns a pointer to a string in static storage which will be overwritten by subsequent calls.  This pointer must not be freed.  On failure, NULL is returned

@lukefromdc
Copy link
Member

OK, that part is probably the same everywhere, good to to

@pyhalov
Copy link
Contributor Author

pyhalov commented Nov 13, 2018

Note, that last change (s/return/exit/) will fail unless #387 is also applied. I was a bit puzzled, why we can't exit() from child on error, when we should (we don't want to run duplicate process). Now we know the reason :)

@lukefromdc
Copy link
Member

Any more updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants